Keep attribution consistent with vendor links
Three paths could leave a catalog row's attribution out of step with its common_third_party_id. A FIRST_PARTY reclassification in the mapping worker kept a stale org ThirdParty link instead of clearing it. The upsert requeued terminal FIRST_PARTY rows for enrichment on a vendor they never adopt, since the vendor-preservation clause nulls it. And the proboctl upsert command did not normalize the verdict when an operator linked or unlinked a vendor without passing --attribution. Clear the org link on a first-party verdict, exclude FIRST_PARTY rows from the enrichment requeue, and have the CLI downgrade THIRD_PARTY to UNDETERMINED on unlink and promote UNDETERMINED to THIRD_PARTY on link. Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
@@ -309,16 +309,20 @@ SET
|
||||
-- re-queued for enrichment: the enrichment agent leaves descriptions
|
||||
-- blank when it cannot substantiate a purpose, and knowing the vendor
|
||||
-- gives it a second, better-informed attempt. The attempt counter is
|
||||
-- reset so the re-armed row gets a fresh retry budget.
|
||||
-- reset so the re-armed row gets a fresh retry budget. A terminal
|
||||
-- FIRST_PARTY row never gains a vendor (the clause above discards the
|
||||
-- incoming one), so it must never re-arm on a vendor it did not adopt.
|
||||
enrichment_requested_at = CASE
|
||||
WHEN common_tracker_patterns.description = ''
|
||||
WHEN common_tracker_patterns.attribution <> 'FIRST_PARTY'
|
||||
AND common_tracker_patterns.description = ''
|
||||
AND common_tracker_patterns.common_third_party_id IS NULL
|
||||
AND EXCLUDED.common_third_party_id IS NOT NULL
|
||||
THEN NOW()
|
||||
ELSE common_tracker_patterns.enrichment_requested_at
|
||||
END,
|
||||
enrichment_attempts = CASE
|
||||
WHEN common_tracker_patterns.description = ''
|
||||
WHEN common_tracker_patterns.attribution <> 'FIRST_PARTY'
|
||||
AND common_tracker_patterns.description = ''
|
||||
AND common_tracker_patterns.common_third_party_id IS NULL
|
||||
AND EXCLUDED.common_third_party_id IS NOT NULL
|
||||
THEN 0
|
||||
@@ -330,7 +334,8 @@ SET
|
||||
-- unrecoverable: the stale-recovery sweep skips any row whose payload
|
||||
-- is non-null, so the re-claimed-but-never-finished row never requeues.
|
||||
enrichment = CASE
|
||||
WHEN common_tracker_patterns.description = ''
|
||||
WHEN common_tracker_patterns.attribution <> 'FIRST_PARTY'
|
||||
AND common_tracker_patterns.description = ''
|
||||
AND common_tracker_patterns.common_third_party_id IS NULL
|
||||
AND EXCLUDED.common_third_party_id IS NOT NULL
|
||||
THEN NULL
|
||||
|
||||
Reference in New Issue
Block a user