Skip to content

Commit

Permalink
build fix
Browse files Browse the repository at this point in the history
  • Loading branch information
layanmoyura committed Feb 16, 2025
1 parent 9b99dbd commit 4a09329
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/components/LetterboxdDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Input } from '@/components/ui/input';
import { Button } from '@/components/ui/button';
import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, LineChart, Line } from 'recharts';
import { Film, Star, Calendar } from 'lucide-react';
import { watch } from 'fs';

const LetterboxdStats = () => {
const [username, setUsername] = useState('');
Expand Down Expand Up @@ -61,7 +60,7 @@ const LetterboxdStats = () => {
recentFilms: films.slice(0, 5),
watchesByMonth: calculateWatchesByMonth(films),
year: calculateYearWatched(films),
watchesByDate: calculateWatchedByDate(films),
watchesByDate: fillMissingDates(calculateWatchedByDate(films)),
};

setStats(statsData);
Expand Down Expand Up @@ -168,6 +167,28 @@ const LetterboxdStats = () => {
}));
};

function fillMissingDates(watchesByDate: { date: string; count: number; }[]): any[] {
const filledDates: { date: string; count: number }[] = [];
const dateMap: { [key: string]: number } = {};

watchesByDate.forEach(entry => {
dateMap[entry.date] = entry.count;
});

const startDate = new Date(watchesByDate[watchesByDate.length - 1].date);
const endDate = new Date(watchesByDate[0].date);

for (let d = startDate; d <= endDate; d.setDate(d.getDate() + 1)) {
const dateStr = d.toISOString().split('T')[0];
filledDates.push({
date: dateStr,
count: dateMap[dateStr] || 0
});
}

return filledDates;
}

return (
<div className="container mx-auto p-4 space-y-6">
<div className="flex flex-col items-center gap-4">
Expand Down

0 comments on commit 4a09329

Please sign in to comment.