28 lines
905 B
Go
28 lines
905 B
Go
package main
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"fmt"
|
||
|
|
"log"
|
||
|
|
|
||
|
|
"github.com/descrybe/descrybe-v2/apps/api/internal/processing"
|
||
|
|
"github.com/google/uuid"
|
||
|
|
"github.com/jackc/pgx/v5/pgxpool"
|
||
|
|
)
|
||
|
|
|
||
|
|
// backfillA1ProcessedAttributes rewrites A1 processed_products.attributes and
|
||
|
|
// processed_attributes with AttrsForPersist + category_attributes allowlists
|
||
|
|
// (same rules as processOne). Use -mode backfill-attributes for polluted local DBs
|
||
|
|
// where poll already looked clean but the catalog row still stored feed junk.
|
||
|
|
func backfillA1ProcessedAttributes(ctx context.Context, pg *pgxpool.Pool, companyID uuid.UUID) (int64, error) {
|
||
|
|
n, err := processing.BackfillCompanyProcessedAttributes(ctx, pg, companyID)
|
||
|
|
if err != nil {
|
||
|
|
return 0, fmt.Errorf("A1 attributes backfill: %w", err)
|
||
|
|
}
|
||
|
|
return n, nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func logAttributesBackfillResult(updated int64) {
|
||
|
|
log.Printf("attributes backfill (A1): processed_updated=%d", updated)
|
||
|
|
}
|