This commit is contained in:
2026-08-16 18:18:39 +02:00
parent b19373e2a4
commit d981147ff2
18 changed files with 20707 additions and 20497 deletions
@@ -41,9 +41,19 @@ type FixCompanyCatalogResult struct {
WeakHashesCleared int `json:"weak_hashes_cleared"`
CategoriesBackfilled int `json:"categories_backfilled"`
// MappedCategoriesBackfilled is processed → mapped_data.category copies.
MappedCategoriesBackfilled int `json:"mapped_categories_backfilled"`
// Coverage after Fix (Products UI reads mapped_data.category for raw rows).
TaxonomyCategories int64 `json:"taxonomy_categories"`
MappedWithCategory int64 `json:"mapped_with_category"`
MappedWithoutCategory int64 `json:"mapped_without_category"`
ProcessedWithCategory int64 `json:"processed_with_category"`
ProcessedWithoutCategory int64 `json:"processed_without_category"`
// Hashes / Categories alias the long names for flash.admin.fixA1Success.
Hashes int `json:"hashes"`
Categories int `json:"categories"`
// MappedBackfilled aliases mapped_categories_backfilled for flash {mapped_backfilled}.
MappedBackfilled int `json:"mapped_backfilled"`
DescriptionsNormalized int `json:"descriptions_normalized"`
DescriptionsBackfilled int `json:"descriptions_backfilled"`
@@ -106,6 +116,14 @@ func FixCompanyCatalog(ctx context.Context, pool *pgxpool.Pool, companyID uuid.U
out.MetaBackfilled = hygiene.MetaBackfilled
out.ProductsScanned = hygiene.ProductsScanned
if opts.BackfillCategories {
mappedN, err := BackfillMappedCategoriesFromProcessed(ctx, pool, companyID)
if err != nil {
return out, fmt.Errorf("mapped category backfill: %w", err)
}
out.MappedCategoriesBackfilled = int(mappedN)
}
sanitized, err := BackfillCompanyProcessedAttributes(ctx, pool, companyID)
if err != nil {
return out, fmt.Errorf("sanitize attributes: %w", err)
@@ -119,9 +137,24 @@ func FixCompanyCatalog(ctx context.Context, pool *pgxpool.Pool, companyID uuid.U
out.ReprocessNeededCount = needed
out.ReprocessSampleRawProductIDs = sample
// Short keys for flash.admin.fixA1Success {prompts,hashes,categories}.
mWith, mWithout, taxonomy, err := CountMappedCategoryCoverage(ctx, pool, companyID)
if err != nil {
return out, err
}
out.MappedWithCategory = mWith
out.MappedWithoutCategory = mWithout
out.TaxonomyCategories = taxonomy
pWith, pWithout, err := CountProcessedCategoryCoverage(ctx, pool, companyID)
if err != nil {
return out, err
}
out.ProcessedWithCategory = pWith
out.ProcessedWithoutCategory = pWithout
// Short keys for flash.admin.fixA1Success {prompts,hashes,categories,mapped_backfilled}.
out.Prompts = out.CategoryPromptsUpdated
out.Hashes = out.WeakHashesCleared
out.Categories = out.CategoriesBackfilled
out.MappedBackfilled = out.MappedCategoriesBackfilled
return out, nil
}