From 0b6e28cdb2e4678292a26f380b36285ac1d1b104 Mon Sep 17 00:00:00 2001 From: lgou2w Date: Sat, 6 Jul 2024 17:26:54 +0800 Subject: [PATCH] fix: gacha calendar days missing bangboo data --- .../gacha/chart/GachaChartCalendar.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/components/gacha/chart/GachaChartCalendar.tsx b/src/components/gacha/chart/GachaChartCalendar.tsx index e3687de..6b56e56 100644 --- a/src/components/gacha/chart/GachaChartCalendar.tsx +++ b/src/components/gacha/chart/GachaChartCalendar.tsx @@ -34,8 +34,8 @@ export default function GachaChartCalendar () { }, [] as CalendarDatum[]) const metadataByDay: Record = {} - Object.entries(aggregatedValues.metadata).forEach(([, value]) => { - for (const record of value.values) { + function mergeMetadataByDays (records: typeof aggregatedValues.values) { + for (const record of records) { const day = dayjs(record.time).format('YYYY-MM-DD') if (!metadataByDay[day]) { metadataByDay[day] = { golden: 0, purple: 0, blue: 0 } @@ -48,7 +48,17 @@ export default function GachaChartCalendar () { metadataByDay[day].blue += 1 } } - }) + } + + Object + .entries(aggregatedValues.metadata) + .forEach(([, value]) => { + mergeMetadataByDays(value.values) + }) + + if (bangboo) { + mergeMetadataByDays(bangboo.values) + } const now = dayjs() const from = now.subtract(1, 'year')