chore(jobs): align log keys + add prune no-op test + down-migration comment

Cross-cutting review polish:
- worker.go: id/type → job_id/job_type; one stray attempts → attempt for
  consistency with the other 4 sites in the same file.
- runners/workspace_fetch.go: ws_id → workspace_id (matches the dispatched
  notify.Message metadata key).
- runners/worktree_prune.go: id → worktree_id (same reason).
- runners/worktree_prune_test.go: add TestWorktreePrune_NoRowsIsNoOp for
  symmetry with the no-op tests in the other 4 runner test files.
- migrations/0005_jobs.down.sql: comment that DROP TABLE jobs cascades to
  drop the three idx_jobs_* indexes automatically.
This commit is contained in:
2026-05-06 11:52:17 +08:00
parent cf1ec7b1c6
commit f6089ac5fb
5 changed files with 39 additions and 20 deletions
+5 -5
View File
@@ -75,7 +75,7 @@ func (r *WorkspaceFetch) Run(ctx context.Context) {
func (r *WorkspaceFetch) fetchOne(ctx context.Context, t WorkspaceFetchTarget) {
ok, err := r.repo.MarkSyncing(ctx, t.ID)
if err != nil {
r.log.Error("workspace_fetch.mark_syncing", "ws_id", t.ID, "err", err.Error())
r.log.Error("workspace_fetch.mark_syncing", "workspace_id", t.ID, "err", err.Error())
return
}
if !ok {
@@ -85,7 +85,7 @@ func (r *WorkspaceFetch) fetchOne(ctx context.Context, t WorkspaceFetchTarget) {
if fetchErr := r.gitr.Fetch(ctx, t.MainPath, t.ID); fetchErr != nil {
msg := truncate(fetchErr.Error(), 2000)
if err := r.repo.MarkFetchResult(ctx, t.ID, false, msg); err != nil {
r.log.Error("workspace_fetch.mark_fail", "ws_id", t.ID, "err", err.Error())
r.log.Error("workspace_fetch.mark_fail", "workspace_id", t.ID, "err", err.Error())
return
}
if derr := r.disp.Dispatch(ctx, notify.Message{
@@ -101,13 +101,13 @@ func (r *WorkspaceFetch) fetchOne(ctx context.Context, t WorkspaceFetchTarget) {
},
CreatedAt: time.Now().UTC(),
}); derr != nil {
r.log.Error("workspace_fetch.dispatch", "ws_id", t.ID, "err", derr.Error())
r.log.Error("workspace_fetch.dispatch", "workspace_id", t.ID, "err", derr.Error())
}
r.log.Warn("workspace_fetch.failed", "ws_id", t.ID, "err", msg)
r.log.Warn("workspace_fetch.failed", "workspace_id", t.ID, "err", msg)
return
}
if err := r.repo.MarkFetchResult(ctx, t.ID, true, ""); err != nil {
r.log.Error("workspace_fetch.mark_ok", "ws_id", t.ID, "err", err.Error())
r.log.Error("workspace_fetch.mark_ok", "workspace_id", t.ID, "err", err.Error())
}
}