feat(portal): add SSR operations and exclusive groups
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
export interface DailyCount {
|
||||
day: string;
|
||||
count: number;
|
||||
}
|
||||
|
||||
export function fillDailySeries(rows: DailyCount[], end: Date, days: number) {
|
||||
const counts = new Map(rows.map((row) => [row.day, Number(row.count)]));
|
||||
const endDay = new Date(Date.UTC(end.getUTCFullYear(), end.getUTCMonth(), end.getUTCDate()));
|
||||
return Array.from({ length: days }, (_, index) => {
|
||||
const date = new Date(endDay);
|
||||
date.setUTCDate(endDay.getUTCDate() - (days - index - 1));
|
||||
const day = date.toISOString().slice(0, 10);
|
||||
return { day, count: counts.get(day) ?? 0 };
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user