This commit is contained in:
2026-08-16 16:57:36 +02:00
parent 96f8c1115c
commit 532d439c41
106 changed files with 10147 additions and 494 deletions
+13 -1
View File
@@ -9,6 +9,10 @@ import (
"github.com/jackc/pgx/v5/pgxpool"
)
// cloneProcessedFieldSourcesSQL copies field_sources but drops enhance_input_hash
// so the destination's first process cannot hash-skip a thin prior description.
const cloneProcessedFieldSourcesSQL = "COALESCE(pp.field_sources, '{}'::jsonb) - 'enhance_input_hash'"
// CloneResult summarizes a company catalog clone (source unchanged).
type CloneResult struct {
SourceCompanyID uuid.UUID `json:"source_company_id"`
@@ -382,7 +386,7 @@ func cloneCompanyCatalog(ctx context.Context, pool *pgxpool.Pool, src, dest uuid
pp.meta_description,
pp.last_transition_at,
pp.structured_description,
pp.field_sources,
` + cloneProcessedFieldSourcesSQL + `,
pp.created_at,
now(),
COALESCE(pp.ai_provider_mode, 'internal'),
@@ -452,6 +456,14 @@ func cloneCompanyCatalog(ctx context.Context, pool *pgxpool.Pool, src, dest uuid
return nil, fmt.Errorf("reset raw processing flags: %w", err)
}
// Drop skip hashes still present on weak / title-echo localized descriptions
// (field_sources hash is already stripped in the INSERT above).
hashRepair, err := repairWeakEnhanceHashesTx(ctx, tx, dest)
if err != nil {
return nil, fmt.Errorf("repair weak enhance hashes: %w", err)
}
add("weak_enhance_hashes_cleared", hashRepair.Cleared)
if err := tx.Commit(ctx); err != nil {
return nil, err
}