Skip to content

feat(seed): derive created_at/updated_at from git history - #65

Merged
Seungpyo1007 merged 2 commits into
mainfrom
feat/git-timestamps
Sep 17, 2026
Merged

Seungpyo1007 merged 2 commits into
mainfrom
feat/git-timestamps

Conversation

@Seungpyo1007

Copy link
Copy Markdown
Member

Second half of making the dump deterministic (first half: #63, stable ids).

Symptom. After #63 a re-dump of unchanged data still touched cpus, socs, smartphones, tablets, watches, pdas, laptops, monitors, software and websites — but not brands or gpus. Diffing a page showed the whole difference:

-  "created_at": "2026-09-17T16:59:52.980136",
+  "created_at": "2026-09-17T17:54:57.390521",

seed rebuilds the database per dump, so _utcnow() stamped "when the dump ran". brands/gpus were stable only because their read schemas omit both fields.

Change. _git_timestamps() runs one git log --reverse --relative --name-only --diff-filter=AM over data/ and maps each record path to (first commit, last commit). _row() applies it at insert. No git checkout → empty map → model defaults, as before.

Checks. tests/unit/test_git_timestamps.py (3 tests) — first/last tracking, repeat-run agreement, non-repo fallback. ruff and mypy clean; full suite has the same 28 pre-existing local failures.

The first test caught a real bug before CI did: git log reported repo-relative paths while records carry data-relative ones, so nothing matched until --relative.

Refs #1

With ids fixed, a second dump of unchanged data still rewrote every page
in 10 of 12 collections. The only difference was the two timestamps: the
database is rebuilt for each dump, so they recorded when the dump ran, not
when the record changed. brands and gpus were the only stable collections
because their schemas do not expose them.

One `git log` pass over data/ maps each record to its first and last commit
time. Outside a git checkout the map is empty and the model defaults stand.

Refs #1
Brand and DiscreteGPU have no created_at/updated_at, so assigning them
raised ValueError on every brand insert.

Refs #1
@Seungpyo1007
Seungpyo1007 merged commit c9239ba into main Sep 17, 2026
1 check passed
Seungpyo1007 added a commit that referenced this pull request Sep 17, 2026
With the default depth-1 checkout, git log sees one commit, so every
record reported the tip commit time — the dump-refresh PR after #65 showed
all pages sharing a single timestamp.

Refs #1
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