Skip to content

Backfill real star/fork history instead of starting from one dot - #3

Merged
squid-protocol merged 1 commit into
mainfrom
feature/star-fork-history-backfill
Jul 31, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
feature/star-fork-history-backfill

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

  • Reconstructs real star/fork history from each event's own timestamp (starred_at via the stargazers endpoint's star+json media type; created_at per fork) instead of only ever having today's snapshot. Confirmed on gitgalaxy: 119 days of real history, not one dot.
  • Self-correcting: re-derived from the live list every run, not a one-time backfill script.
  • Fixes a mislabeling from the previous PR — "(14d)" implied a rolling window; GitHub's traffic API actually returns one entry per calendar day (confirmed against the docs), it just only exposes the trailing 14 of them. Relabeled "(daily)".
  • Documents why cloners/views are deliberately NOT cumsum'd the way stars/forks now are: summing daily "uniques" across days double-counts repeat visitors, since GitHub's per-day aggregate retains no cross-day identity. No valid transform recovers a true cumulative-unique count from these — an information-theoretic limit, not a processing gap. (Same issue already exists, less visibly, in the pre-existing "Cumulative Downloads" chart's cumsum of daily unique_cloners — flagged in the commit message, not touched in this PR.)

Testing

Full fetch_and_store() run against a scratch DB copy — 119 backfilled repo_stats rows matching real stargazer/fork dates, all 6 charts render without error.

🤖 Generated with Claude Code

GitHub exposes when each star/fork happened (starred_at on the
stargazers endpoint with the star+json media type; created_at on each
fork), so instead of waiting weeks for daily repo_stats snapshots to
build a trend, reconstruct the real historical curve right now and
backfill every day since the first star/fork. Confirmed on gitgalaxy:
119 days of real history (3 stars on 2026-04-04, growing to 46 by
today), instead of a single point.

Re-derived from the live list on every run (not a one-time backfill
script), so it's self-correcting: a missed day heals itself, and an
unstarred repo's historical curve adjusts down too, which is more
honest than a frozen snapshot would be. Known, unfixable caveat: only
sees currently-existing stars/forks -- one that was later
removed/deleted won't appear in today's list, so a historical peak
before a removal is invisible (GitHub doesn't expose removal events).

Also fixes a mislabeling from the previous PR: "Unique Cloners (14d)"
implied each point was a rolling 14-day window. Checked GitHub's docs
directly -- traffic/clones returns one entry per CALENDAR DAY (GitHub
just only exposes the trailing 14 days of them at any given time).
Relabeled "(daily)", and added an explicit code comment on why these
two series are deliberately NOT cumsum'd the way stars/forks are:
summing daily "uniques" across days double-counts anyone who visited
on more than one day, since GitHub's per-day uniqueness aggregate
retains no cross-day identity to de-overlap against. There is no
valid transform that recovers true cumulative-unique-visitor counts
from these aggregates -- an information-theoretic limit, not a
data-processing gap (the same repeat-visitor inflation already exists,
less visibly, in the pre-existing "Cumulative Downloads" chart's own
cumsum of daily unique_cloners -- flagged, not touched here).

Tested end-to-end against a scratch copy of traffic_metrics.db: full
fetch_and_store() run, 119 backfilled repo_stats rows for gitgalaxy
matching the real stargazer/fork timestamps, all 6 charts render
without error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant