feat(commits): add source and manual_minutes fields
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
1cb05f4689
commit
65b09170af
2 changed files with 60 additions and 0 deletions
|
|
@ -223,6 +223,58 @@ async function ensureCommitSummaryFields(pb: PocketBase): Promise<void> {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the `source` and `manual_minutes` fields to commits, for Phase 7's
|
||||
* logged work entries.
|
||||
*
|
||||
* Backfilled to "git" for every existing row — every commit ingested before
|
||||
* this phase came from the repository, by definition.
|
||||
*
|
||||
* Re-runs are safe: fields are not duplicated, and backfill only touches rows
|
||||
* where source is still unset.
|
||||
*/
|
||||
async function ensureManualEntryFields(pb: PocketBase): Promise<void> {
|
||||
const commits = await pb.collections.getOne("commits");
|
||||
const have = new Set(commits.fields.map((f: { name: string }) => f.name));
|
||||
|
||||
const additions = [
|
||||
{
|
||||
name: "source",
|
||||
type: "select",
|
||||
required: false,
|
||||
maxSelect: 1,
|
||||
values: ["git", "manual"],
|
||||
},
|
||||
{ name: "manual_minutes", type: "number", required: false, onlyInt: true },
|
||||
];
|
||||
|
||||
const fields = [...(commits.fields as unknown[])];
|
||||
let changed = false;
|
||||
|
||||
for (const field of additions) {
|
||||
if (!have.has(field.name)) {
|
||||
fields.push({ ...field, presentable: false, hidden: false, system: false });
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
await pb.collections.update(commits.id, { fields });
|
||||
console.log(" + commits fields: source, manual_minutes");
|
||||
} else {
|
||||
console.log(" = manual entry fields already present");
|
||||
}
|
||||
|
||||
const unset = await pb.collection("commits").getFullList({
|
||||
filter: 'source = ""',
|
||||
fields: "id",
|
||||
});
|
||||
for (const commit of unset) {
|
||||
await pb.collection("commits").update(commit.id, { source: "git" });
|
||||
}
|
||||
console.log(` = commit source backfilled (${unset.length} row(s))`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the `narrative`, `narrative_version`, `narrative_shas` fields to cards.
|
||||
*
|
||||
|
|
@ -946,6 +998,9 @@ async function main(): Promise<void> {
|
|||
// Add the per-commit summary fields used by Phase 3b's AI one-liner job.
|
||||
await ensureCommitSummaryFields(pb);
|
||||
|
||||
// Add the source/manual_minutes fields for Phase 7's logged work entries.
|
||||
await ensureManualEntryFields(pb);
|
||||
|
||||
// Add the card number field and backfill existing cards.
|
||||
await ensureCardNumbers(pb);
|
||||
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ export interface CommentRecord extends BaseRecord {
|
|||
}
|
||||
|
||||
export type CommitLinkSource = "explicit" | "scope" | "manual" | "none";
|
||||
export type CommitSource = "git" | "manual";
|
||||
|
||||
export interface ProjectMetricsRecord extends BaseRecord {
|
||||
project: string;
|
||||
|
|
@ -142,6 +143,10 @@ export interface CommitRecord extends BaseRecord {
|
|||
summary_version: number;
|
||||
/** Consecutive failed attempts. Capped so a poison message stops retrying. */
|
||||
summary_attempts: number;
|
||||
/** "git" for every ingested commit, "manual" for a logged entry. */
|
||||
source: CommitSource;
|
||||
/** Only meaningful when source is "manual" — the owner's declared minutes. */
|
||||
manual_minutes: number;
|
||||
}
|
||||
|
||||
export interface ActivityRecord extends Omit<BaseRecord, "updated"> {
|
||||
|
|
|
|||
Loading…
Reference in a new issue