diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2025-10-28 10:24:19 +0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-28 09:24:19 +0300 |
| commit | 5cb8327758b2636a1f82d9659f89464b4dbd6093 (patch) | |
| tree | bf430912c40a72733a1efbe1967e5baa73591c43 | |
| parent | feat/frontend: homepage with timeline and recent scores (diff) | |
| download | lphub-5cb8327758b2636a1f82d9659f89464b4dbd6093.tar.gz lphub-5cb8327758b2636a1f82d9659f89464b4dbd6093.tar.bz2 lphub-5cb8327758b2636a1f82d9659f89464b4dbd6093.zip | |
fix/frontend: timeline to continue until today (#292)
Diffstat (limited to '')
| -rw-r--r-- | frontend/src/pages/Homepage.tsx | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/frontend/src/pages/Homepage.tsx b/frontend/src/pages/Homepage.tsx index 88290dd..77dc220 100644 --- a/frontend/src/pages/Homepage.tsx +++ b/frontend/src/pages/Homepage.tsx | |||
| @@ -20,7 +20,7 @@ const Homepage: React.FC = () => { | |||
| 20 | }; | 20 | }; |
| 21 | const sortedData = [...data].sort((a, b) => new Date(a.date).getTime() - new Date(b.date).getTime()); | 21 | const sortedData = [...data].sort((a, b) => new Date(a.date).getTime() - new Date(b.date).getTime()); |
| 22 | const startDate = new Date(sortedData[0].date); | 22 | const startDate = new Date(sortedData[0].date); |
| 23 | const endDate = new Date(sortedData[sortedData.length - 1].date); | 23 | const today = new Date(); |
| 24 | 24 | ||
| 25 | const result: PortalCountData[] = []; | 25 | const result: PortalCountData[] = []; |
| 26 | let currentDate = new Date(startDate.getFullYear(), startDate.getMonth(), 1); | 26 | let currentDate = new Date(startDate.getFullYear(), startDate.getMonth(), 1); |
| @@ -28,7 +28,7 @@ const Homepage: React.FC = () => { | |||
| 28 | let dataIndex = 0; | 28 | let dataIndex = 0; |
| 29 | let currentCount = sortedData[0].count; | 29 | let currentCount = sortedData[0].count; |
| 30 | 30 | ||
| 31 | while (currentDate <= endDate) { | 31 | while (currentDate <= today) { |
| 32 | while (dataIndex < sortedData.length && new Date(sortedData[dataIndex].date) <= currentDate) { | 32 | while (dataIndex < sortedData.length && new Date(sortedData[dataIndex].date) <= currentDate) { |
| 33 | currentCount = sortedData[dataIndex].count; | 33 | currentCount = sortedData[dataIndex].count; |
| 34 | dataIndex++; | 34 | dataIndex++; |
| @@ -44,7 +44,6 @@ const Homepage: React.FC = () => { | |||
| 44 | currentDate = nextDate; | 44 | currentDate = nextDate; |
| 45 | } | 45 | } |
| 46 | } | 46 | } |
| 47 | |||
| 48 | return result; | 47 | return result; |
| 49 | }; | 48 | }; |
| 50 | 49 | ||