[GH-ISSUE #5] Bug: First observation of an asset inflates daily delta (re-uploads/new IDs) #2

Open
opened 2026-10-26 22:08:19 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @benceruleanlu on GitHub (Nov 9, 2025).
Original GitHub issue: https://github.com/Comfy-Org/download-data/issues/5

Summary
Daily summary treats missing prior snapshot as if today’s full download_count is the delta, which can spike totals when an asset is first seen (including re-uploads with a new asset_id).

Evidence

  • CASE expression: scripts/fetch-data.mjs:346–357 (and similar) uses
    WHEN old.download_count IS NULL THEN new.download_count

Proposed Fix

  • Treat first observation as 0 delta:
    CASE WHEN old.download_count IS NULL THEN 0 ELSE new.download_count - old.download_count END
  • Alternatively detect first_seen date per asset_id (MIN(date)) and force 0 when new.date == first_seen.

Acceptance Criteria

  • Newly appearing assets no longer cause one-day spikes
  • Subsequent days reflect true diffs
Originally created by @benceruleanlu on GitHub (Nov 9, 2025). Original GitHub issue: https://github.com/Comfy-Org/download-data/issues/5 Summary Daily summary treats missing prior snapshot as if today’s full download_count is the delta, which can spike totals when an asset is first seen (including re-uploads with a new asset_id). Evidence - CASE expression: scripts/fetch-data.mjs:346–357 (and similar) uses WHEN old.download_count IS NULL THEN new.download_count Proposed Fix - Treat first observation as 0 delta: CASE WHEN old.download_count IS NULL THEN 0 ELSE new.download_count - old.download_count END - Alternatively detect first_seen date per asset_id (MIN(date)) and force 0 when new.date == first_seen. Acceptance Criteria - Newly appearing assets no longer cause one-day spikes - Subsequent days reflect true diffs
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Comfy-Org/download-data#2
No description provided.