fixes
This commit is contained in:
@@ -7,11 +7,13 @@
|
||||
// part of npm run seed:a1 (skipped on import + cleared after). Use
|
||||
// -mode recover-jobs only when restoring legacy job history from a MySQL dump.
|
||||
//
|
||||
// After reimport, legacy per-category GPT prompts are overlaid from
|
||||
// scripts/seed/a1-category-prompts.json (Name→Prompt export), matched by
|
||||
// normalized category name, with v1 placeholders rewritten to {{name}} /
|
||||
// {{description}}. Use -skip-category-prompts to skip, or
|
||||
// -mode apply-category-prompts to overlay without a full wipe/reimport.
|
||||
// After reimport, per-category enhance prompts are overlaid from
|
||||
// scripts/seed/a1-category-prompts.json (Name list), matched by normalized
|
||||
// category name, writing aiprompts.CategoryEnhanceUserTemplate (JSON-compatible;
|
||||
// includes {{attrs}}/{{language}}). Legacy HTML bodies in that JSON are ignored.
|
||||
// Use -skip-category-prompts to skip, or -mode apply-category-prompts to overlay
|
||||
// without a full wipe/reimport. For polluted A1+Platform Demo prompts without
|
||||
// reimport, run: go run ./cmd/repair-category-prompts -apply
|
||||
//
|
||||
// Categories: dump/archive store assignment on processed_products.category
|
||||
// (category unique_id). Feed mappings do not map category. After reimport,
|
||||
@@ -26,6 +28,9 @@
|
||||
// exported/imported as-is (skip-processed must not strip them). For a
|
||||
// polluted local DB without a full wipe, use -mode backfill-categories.
|
||||
// Fixture EANs are purged from non-A1 tenants automatically.
|
||||
// Processed attribute junk (poll clean, DB still has zavora/vzmetenje, …): use
|
||||
// -mode backfill-attributes — same SanitizeProductAttributes + category allowlist
|
||||
// as processOne/enhance.
|
||||
//
|
||||
// Usage:
|
||||
//
|
||||
@@ -34,6 +39,7 @@
|
||||
// go run ./cmd/seed-a1 -mode apply-category-prompts -file ../../scripts/seed/a1-demo-data.sql.gz
|
||||
// go run ./cmd/seed-a1 -mode recover-jobs -mysql-dump path/to/descrybe_new.sql
|
||||
// go run ./cmd/seed-a1 -mode backfill-categories -mysql-dump path/to/descrybe_new.sql
|
||||
// go run ./cmd/seed-a1 -mode backfill-attributes
|
||||
//
|
||||
// DATABASE_URL / -postgres required.
|
||||
// Day-to-day: `npm run seed:a1` (reimport + category prompts + mapped category backfill). Maintainer snapshot: `npm run seed:a1:export`.
|
||||
@@ -77,7 +83,7 @@ type tableSpec struct {
|
||||
|
||||
func main() {
|
||||
postgresURL := flag.String("postgres", os.Getenv("DATABASE_URL"), "Postgres URL (DATABASE_URL)")
|
||||
mode := flag.String("mode", "reimport", "export | reimport | recover-jobs | apply-category-prompts | backfill-categories")
|
||||
mode := flag.String("mode", "reimport", "export | reimport | recover-jobs | apply-category-prompts | backfill-categories | backfill-attributes")
|
||||
file := flag.String("file", "", "gzipped seed archive path (required for export/reimport)")
|
||||
mysqlDump := flag.String("mysql-dump", os.Getenv("SEED_A1_MYSQL_DUMP"), "mysqldump path for recover-jobs / backfill-categories (or SEED_A1_MYSQL_DUMP)")
|
||||
company := flag.String("company", defaultA1CompanyID, "Postgres companies.id for A1")
|
||||
@@ -95,7 +101,8 @@ func main() {
|
||||
}
|
||||
|
||||
modeVal := strings.ToLower(strings.TrimSpace(*mode))
|
||||
if modeVal != "recover-jobs" && modeVal != "apply-category-prompts" && modeVal != "backfill-categories" && strings.TrimSpace(*file) == "" {
|
||||
needsFile := modeVal != "recover-jobs" && modeVal != "apply-category-prompts" && modeVal != "backfill-categories" && modeVal != "backfill-attributes"
|
||||
if needsFile && strings.TrimSpace(*file) == "" {
|
||||
log.Fatal("-file is required (e.g. ../../scripts/seed/a1-demo-data.sql.gz)")
|
||||
}
|
||||
dumpPath := resolveMySQLDumpPath(*mysqlDump)
|
||||
@@ -184,13 +191,19 @@ func main() {
|
||||
}
|
||||
res.PurgedOtherRaw, res.PurgedOtherPP = rawN, ppN
|
||||
logCategoryBackfillResult(res, dumpPath)
|
||||
case "backfill-attributes":
|
||||
n, err := backfillA1ProcessedAttributes(ctx, pg, companyID)
|
||||
if err != nil {
|
||||
log.Fatalf("backfill-attributes: %v", err)
|
||||
}
|
||||
logAttributesBackfillResult(n)
|
||||
case "recover-jobs":
|
||||
if err := recoverJobsFromMySQLDump(ctx, pg, companyID, dumpPath); err != nil {
|
||||
log.Fatalf("recover-jobs: %v", err)
|
||||
}
|
||||
log.Printf("recovered A1 processing jobs into company %s from %s", companyID, dumpPath)
|
||||
default:
|
||||
log.Fatalf("unknown -mode %q (want export|reimport|recover-jobs|apply-category-prompts|backfill-categories)", *mode)
|
||||
log.Fatalf("unknown -mode %q (want export|reimport|recover-jobs|apply-category-prompts|backfill-categories|backfill-attributes)", *mode)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user