Unify storage ID queries under one implementation

This commit is contained in:
Ian Gulliver
2026-10-21 11:58:42 -07:00
parent 069474e6aa
commit abe4d7c9d5
6 changed files with 37 additions and 117 deletions
+1 -16
View File
@@ -78,26 +78,11 @@ func (s *Store) RunningReviews(ctx context.Context) ([]api.Review, error) {
}
func (s *Store) LatestDoneStages(ctx context.Context) ([]string, error) {
rows, err := s.db.QueryContext(ctx, `
return queryIDs(ctx, s.db, `
SELECT r.id FROM reviews r JOIN tasks t ON t.id = r.task_id
WHERE t.status = ? AND r.state = ? AND r.definition_id IS NOT NULL
AND r.snapshot_n = (SELECT max(snapshot_n) FROM reviews WHERE task_id = r.task_id)
ORDER BY r.created_at`, string(api.TaskStatusActive), string(api.ReviewStateDone))
if err != nil {
return nil, err
}
defer rows.Close()
ids := []string{}
for rows.Next() {
id := ""
err = rows.Scan(&id)
if err != nil {
return nil, err
}
ids = append(ids, id)
}
return ids, rows.Err()
}
func (s *Store) FinishReview(ctx context.Context, id string, state api.ReviewState, result map[string]any, errText string) error {