Skip to content

Commit bf7c2b2

Browse files
committed
feat: show chart data since Jan 2026 on main page
1 parent 5e68f8d commit bf7c2b2

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

routes/index.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,13 @@ import { DenoVersion } from "components/DenoVersion.tsx";
55
import { LinkToJsonAndErrors } from "components/LinkToJsonAndErrors.tsx";
66
import { Chart } from "islands/Chart.tsx";
77
import { SummaryTable } from "islands/SummaryTable.tsx";
8-
import {
9-
getLatestDaySummary,
10-
getSummariesForLatestMonths,
11-
} from "util/report.ts";
8+
import { getLatestDaySummary, getSummariesSinceMonth } from "util/report.ts";
129
import { DaySummary } from "util/types.ts";
1310

1411
export const handler = define.handlers({
1512
async GET() {
16-
const monthSummaries = await getSummariesForLatestMonths(3);
17-
const monthSummary = monthSummaries[0];
13+
const monthSummaries = await getSummariesSinceMonth("2026-01");
14+
const monthSummary = monthSummaries[monthSummaries.length - 1];
1815
const daySummaries = monthSummaries.reduce(
1916
(acc, month) => Object.assign(acc, month.reports),
2017
{} as Record<string, DaySummary>,

util/report.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,23 @@ export async function getSummariesForLatestMonths(
235235
return summaries;
236236
}
237237

238+
export async function getSummariesSinceMonth(
239+
startMonth: string,
240+
): Promise<MonthSummary[]> {
241+
const current = new Date(startMonth + "-15");
242+
const now = new Date();
243+
const summaries: MonthSummary[] = [];
244+
while (current <= now) {
245+
const monthName = current.toISOString().slice(0, 7);
246+
const summary = await getMonthSummary(monthName);
247+
if (Object.keys(summary.reports).length > 0) {
248+
summaries.push(summary);
249+
}
250+
current.setMonth(current.getMonth() + 1);
251+
}
252+
return summaries;
253+
}
254+
238255
export async function addDaySummaryByDate(
239256
monthSummary: MonthSummary,
240257
date: string,

0 commit comments

Comments
 (0)