Drop reset-enriched flag and add description filter

The --reset-enriched flag was effectively a no-op: the enrichment
worker claims rows solely on enrichment_requested_at, and SetEnriched
rewrites enriched_at regardless, so clearing it never changed whether a
row was re-processed. Remove the flag and the resetEnriched parameter on
RequestEnrichmentByIDs, which now only stamps enrichment_requested_at.

Add a --without-description filter to the list and reenrich commands,
backed by a new described predicate on CommonTrackerPatternFilter, so an
operator can target catalog rows that still lack a description.

Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
Émile Ré
2026-06-08 17:13:16 +02:00
parent 4eb352a61d
commit b0e8e9b812
4 changed files with 64 additions and 29 deletions

View File

@@ -836,29 +836,27 @@ ORDER BY pattern ASC
}
// RequestEnrichmentByIDs arms enrichment on the given common tracker
// patterns. When resetEnriched is true it also clears enriched_at so rows
// that previously reached a terminal state are re-processed. Returns the
// number of rows re-queued. This is the async fallback path; the
// synchronous enricher service is preferred.
// patterns by stamping enrichment_requested_at, which is the only column
// the enrichment worker claims on. Already-enriched rows are re-processed
// too: the worker overwrites enriched_at and the description when it runs.
// Returns the number of rows re-queued. This is the async fallback path;
// the synchronous enricher service is preferred.
func (ps *CommonTrackerPatterns) RequestEnrichmentByIDs(
ctx context.Context,
tx pg.Tx,
ids []gid.GID,
resetEnriched bool,
) (int64, error) {
q := `
UPDATE common_tracker_patterns
SET
enrichment_requested_at = NOW(),
enriched_at = CASE WHEN @reset_enriched THEN NULL ELSE enriched_at END,
updated_at = NOW()
WHERE
id = ANY(@ids)
`
args := pgx.StrictNamedArgs{
"ids": ids,
"reset_enriched": resetEnriched,
"ids": ids,
}
result, err := tx.Exec(ctx, q, args)