diff --git a/scripts/backfill.ts b/scripts/backfill.ts index 1d7f6b7..dc3b9c7 100644 --- a/scripts/backfill.ts +++ b/scripts/backfill.ts @@ -99,6 +99,7 @@ async function main() { deletions: commit.stats?.deletions ?? 0, link_source: "none", url: commit.html_url, + source: "git", }); created += 1; } diff --git a/scripts/setup-remote.ts b/scripts/setup-remote.ts index 55f6da9..ec60db5 100644 --- a/scripts/setup-remote.ts +++ b/scripts/setup-remote.ts @@ -233,7 +233,7 @@ async function ensureCommitSummaryFields(pb: PocketBase): Promise { * Re-runs are safe: fields are not duplicated, and backfill only touches rows * where source is still unset. */ -async function ensureManualEntryFields(pb: PocketBase): Promise { +async function ensureCommitSourceFields(pb: PocketBase): Promise { const commits = await pb.collections.getOne("commits"); const have = new Set(commits.fields.map((f: { name: string }) => f.name)); @@ -245,7 +245,7 @@ async function ensureManualEntryFields(pb: PocketBase): Promise { maxSelect: 1, values: ["git", "manual"], }, - { name: "manual_minutes", type: "number", required: false, onlyInt: true }, + { name: "manual_minutes", type: "number", required: false, onlyInt: true, min: 0 }, ]; const fields = [...(commits.fields as unknown[])]; @@ -262,7 +262,7 @@ async function ensureManualEntryFields(pb: PocketBase): Promise { await pb.collections.update(commits.id, { fields }); console.log(" + commits fields: source, manual_minutes"); } else { - console.log(" = manual entry fields already present"); + console.log(" = commit source fields already present"); } const unset = await pb.collection("commits").getFullList({ @@ -272,7 +272,8 @@ async function ensureManualEntryFields(pb: PocketBase): Promise { for (const commit of unset) { await pb.collection("commits").update(commit.id, { source: "git" }); } - console.log(` = commit source backfilled (${unset.length} row(s))`); + const prefix = unset.length > 0 ? "+" : "="; + console.log(` ${prefix} commit source backfilled (${unset.length} row(s))`); } /** @@ -999,7 +1000,7 @@ async function main(): Promise { await ensureCommitSummaryFields(pb); // Add the source/manual_minutes fields for Phase 7's logged work entries. - await ensureManualEntryFields(pb); + await ensureCommitSourceFields(pb); // Add the card number field and backfill existing cards. await ensureCardNumbers(pb); diff --git a/src/lib/git/ingest.ts b/src/lib/git/ingest.ts index ec1208a..53a51c8 100644 --- a/src/lib/git/ingest.ts +++ b/src/lib/git/ingest.ts @@ -44,6 +44,7 @@ function toRecord(projectId: string, commit: ForgejoCommit) { deletions: commit.stats?.deletions ?? 0, link_source: "none" as const, url: commit.html_url, + source: "git" as const, }; }