Skip to content

Commit

Permalink
fix: gacha calendar days missing bangboo data
Browse files Browse the repository at this point in the history
  • Loading branch information
lgou2w committed Jul 6, 2024
1 parent d3cef22 commit 0b6e28c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/components/gacha/chart/GachaChartCalendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export default function GachaChartCalendar () {
}, [] as CalendarDatum[])

const metadataByDay: Record<string, { golden: number, purple: number, blue: number }> = {}
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 }
Expand All @@ -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')
Expand Down

0 comments on commit 0b6e28c

Please sign in to comment.