Skip to content

Commit

Permalink
handle edge case for ytd selection at beginning of year
Browse files Browse the repository at this point in the history
  • Loading branch information
secondl1ght committed Dec 19, 2023
1 parent b1feefc commit 68b23f6
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions src/routes/dashboard/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -522,26 +522,29 @@
} else {
const latestReport = statsSorted[statsSorted.length - 1];
const dateHistory = getChartHistoryDate();
const reportIsCurrent =
today.getDate() === dateHistory.getDate() &&
today.getMonth() === dateHistory.getMonth() &&
today.getFullYear() === dateHistory.getFullYear();
statsFiltered.push({
...latestReport,
date: `${dateHistory.getFullYear()}-${
dateHistory.getMonth() + 1
}-${dateHistory.getDate()}`,
created_at: dateHistory.toISOString(),
updated_at: dateHistory.toISOString()
});
statsFiltered.push(
...[
{
...latestReport,
date: `${dateHistory.getFullYear()}-${
dateHistory.getMonth() + 1
}-${dateHistory.getDate()}`,
created_at: dateHistory.toISOString(),
updated_at: dateHistory.toISOString()
},
{
...latestReport,
id: latestReport.id + 1,
date: `${today.getFullYear()}-${today.getMonth() + 1}-${today.getDate()}`,
created_at: today.toISOString(),
updated_at: today.toISOString()
}
]
);
if (!reportIsCurrent) {
statsFiltered.push({
...latestReport,
id: latestReport.id + 1,
date: `${today.getFullYear()}-${today.getMonth() + 1}-${today.getDate()}`,
created_at: today.toISOString(),
updated_at: today.toISOString()
});
}
statsFiltered = statsFiltered;
}
Expand Down

0 comments on commit 68b23f6

Please sign in to comment.