This commit is contained in:
greeneclipse committed 2026-10-16 00:55:28 +02:00
1 parent 1e7c7bbfbb
commit feebf7d3c1
12 files changed
+248 -70

No files matched your search

+12
View File
@@ -412,3 +412,15 @@ func TestSanitizeFileName(t *testing.T) {
t.Fatalf("got %q", sanitizeFileName("a b*.csv"))
}
}
// Historical API processing predates origin tagging. Generated fields remain
// visible in Processed without silently transitioning review-state records.
func TestGeneratedProductFilterIncludesLegacyContent(t *testing.T) {
_, where := appendProcessedProductFilters(ProductFilter{Status: "generated"}, nil, nil)
joined := strings.Join(where, " ")
for _, value := range []string{"p.status = 'completed'", "p.processed_name", "p.processed_description", "p.meta_title", "p.meta_description", "needs_review"} {
if !strings.Contains(joined, value) {
t.Fatalf("missing %s in generated filter: %s", value, joined)
}
}
}
+17 -3
View File
@@ -700,9 +700,9 @@ const (
WHEN COALESCE(p.field_sources->>'category', '') IN ('llm', 'vector') THEN ''
ELSE COALESCE(NULLIF(BTRIM(r.mapped_data->>'category'), ''), NULLIF(BTRIM(r.mapped_data->>'category_unique_id'), ''), '')
END`
processedHasNameSQL = `(` + processedPreferredNameSQL + ` <> '')`
processedHasDescriptionSQL = `(` + processedPreferredDescriptionSQL + ` <> '')`
processedHasCategorySQL = `(COALESCE(NULLIF(p.category, ''), '') <> '' AND lower(p.category) <> 'none')`
processedHasNameSQL = `(` + processedPreferredNameSQL + ` <> '')`
processedHasDescriptionSQL = `(` + processedPreferredDescriptionSQL + ` <> '')`
processedHasCategorySQL = `(COALESCE(NULLIF(p.category, ''), '') <> '' AND lower(p.category) <> 'none')`
// Resolve display name / canonical unique_id when products store unique_id, UUID id, or name.
processedCategoryResolveJoin = `
LEFT JOIN LATERAL (
@@ -1071,6 +1071,20 @@ func appendProcessedProductFilters(f ProductFilter, args []any, where []string)
n, n, n, n, n))
}
if f.Status != "" {
// The dashboard's Processed tab must also surface already-generated legacy
// API results. Pre-v16 jobs were not tagged with their origin, so we cannot
// safely approve them in a migration. Include only rows with actual generated
// fields, preserving their original needs_review status and actions.
if f.Status == "generated" {
where = append(where, `(p.status = 'completed' OR
(p.status IN ('needs_review', 'processed') AND (
NULLIF(BTRIM(COALESCE(p.processed_name, '')), '') IS NOT NULL OR
NULLIF(BTRIM(COALESCE(p.processed_description, '')), '') IS NOT NULL OR
NULLIF(BTRIM(COALESCE(p.meta_title, '')), '') IS NOT NULL OR
NULLIF(BTRIM(COALESCE(p.meta_description, '')), '') IS NOT NULL
)))`)
return args, where
}
// needs_review includes legacy pipeline status "processed" (pre-P0-8).
if f.Status == "needs_review" {
where = append(where, "p.status IN ('needs_review', 'processed')")