feat: add sveltekit pages, generate reports
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import type { ReportRoot } from '@duck/types';
|
||||
import { error } from '@sveltejs/kit';
|
||||
import type { Load } from '@sveltejs/kit';
|
||||
import { extractPerTask, getReviewTotals } from '$lib/reports';
|
||||
|
||||
export interface ReportsPageData {
|
||||
report: ReportRoot;
|
||||
rows: ReturnType<typeof extractPerTask>;
|
||||
review: { reviewed: number; pending: number };
|
||||
}
|
||||
|
||||
export const load: Load = async ({ fetch }): Promise<ReportsPageData> => {
|
||||
const res = await fetch('/report.json');
|
||||
if (!res.ok) {
|
||||
throw error(res.status, `report.json not found (${res.status})`);
|
||||
}
|
||||
const report = (await res.json()) as ReportRoot;
|
||||
return {
|
||||
report,
|
||||
rows: extractPerTask(report),
|
||||
review: getReviewTotals(report)
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user