Skip to content

Commit c0f3c44

Browse files
committed
Merge branch 'feat/changelog-1' of github.com:WilcoSp/npmx.dev into feat/changelog-1
2 parents f3c1759 + 435b569 commit c0f3c44

File tree

4 files changed

+104
-84
lines changed

4 files changed

+104
-84
lines changed

app/utils/chart-data-buckets.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,13 @@ export function buildWeeklyEvolution(
3434
if (sorted.length === 0) return []
3535

3636
const rangeStartDate = parseIsoDate(rangeStartIso)
37+
const rangeEndDate = parseIsoDate(rangeEndIso)
3738

38-
// Align from last day with actual data (npm has 1-2 day delay, today is incomplete)
39-
const lastNonZero = sorted.findLast(d => d.value > 0)
40-
const pickerEnd = parseIsoDate(rangeEndIso)
41-
const effectiveEnd = lastNonZero ? parseIsoDate(lastNonZero.day) : pickerEnd
42-
const rangeEndDate = effectiveEnd.getTime() < pickerEnd.getTime() ? effectiveEnd : pickerEnd
43-
44-
// Group into 7-day buckets from END backwards
4539
const buckets = new Map<number, number>()
40+
4641
for (const item of sorted) {
47-
const offset = Math.floor((rangeEndDate.getTime() - parseIsoDate(item.day).getTime()) / DAY_MS)
42+
const itemDate = parseIsoDate(item.day)
43+
const offset = Math.floor((rangeEndDate.getTime() - itemDate.getTime()) / DAY_MS)
4844
if (offset < 0) continue
4945
const idx = Math.floor(offset / 7)
5046
buckets.set(idx, (buckets.get(idx) ?? 0) + item.value)

0 commit comments

Comments
 (0)