fix: record last_eligibility_run_at only when eligibility rules run - #448
Open
mdiapenabc wants to merge 3 commits into
Open
fix: record last_eligibility_run_at only when eligibility rules run#448mdiapenabc wants to merge 3 commits into
mdiapenabc wants to merge 3 commits into
Conversation
Align the BL-14C watermark with "last rules run" instead of "last upsert": bump on rule evaluation (including BL-14C skip), not on protected field refresh. Preserves Hold/Resume and user-set behaviour.
Record the watermark once after upserts from a single rulesRanIds list instead of splitting across rulesRan flags and upsert paths.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
PR #437 introduced
last_eligibility_run_atto fix Hold/Resume (staging was compared against resume effective date). The field was only updated on upsert, but he UI treat it as “last time eligibility ran on this contact.”After a single-contact run where rules evaluate but skip upsert (same status, unchanged staging), Last Eligibility Run stayed stale even though eligibility ran.
This PR aligns behaviour:
last_eligibility_run_at= last time decision rules ran, not last upsert, and not protected field refresh (rules never run there).Hold/Resume and user-set are unchanged: Hold/Resume still do not touch this field; user-set still skips rules when staging is unchanged since last rules run.
What changed
last_eligibility_run_atwhen rules run and skips upsert (narrowUPDATE, no ICM sync side effects)recordEligibilityRunAt(); stop setting it on upsertON CONFLICT UPDATEon_hold, etc.) upserts withrulesRan: false— fields refresh, watermark does not movelast_eligibility_run_atonINSERT(first rules run)How to test
on_hold, Last Eligibility Run unchangednpm test -- src/sync/eligibility/eligibility.service.spec.ts