Skip to content

fix(claims): ensure resolvedAt is set on every resolve path (Closes #… - #267

Open
udeachudivine-spec wants to merge 2 commits into
DigiNodes:mainfrom
udeachudivine-spec:fix/claim-resolved-at-null-check
Open

fix(claims): ensure resolvedAt is set on every resolve path (Closes #…#267
udeachudivine-spec wants to merge 2 commits into
DigiNodes:mainfrom
udeachudivine-spec:fix/claim-resolved-at-null-check

Conversation

@udeachudivine-spec

Copy link
Copy Markdown
Contributor

…219, BE-219)

  • Add resolvedAt nullable timestamp column to Claim entity
  • Add migration 1769600000000-AddClaimResolvedAt with backfill for existing resolved rows (resolvedAt = createdAt as conservative approx)
  • Add claim-resolution.invariant.ts with assertResolvedAtInvariant(), buildResolvedFields(), buildUnresolvedFields() helpers
  • Fix ClaimsService.resolveClaim(): set resolvedAt atomically with resolvedVerdict via buildResolvedFields(); add invariant guard before save; upgrade throw to NotFoundException
  • Fix ClaimResolutionService.resolveClaim(): same atomic set + guard
  • Fix JobsService.computeScores() (automated/oracle path): use buildResolvedFields() so resolvedAt is set on the job-driven path
  • Remove duplicate findOne() override in ClaimsService that shadowed the null-returning implementation with a throwing one
  • Update ClaimFactory: default resolvedAt to null; fix createClaimWithVerdict() to set resolvedAt alongside resolvedVerdict
  • Add claim-resolution.invariant.spec.ts: full invariant unit tests
  • Expand claim-resolution.service.spec.ts: resolveClaim resolvedAt tests (timestamp set, atomic write, finalized=true, verdict mapping)
  • Expand claims.service.spec.ts: resolvedAt timestamp tests, atomicity test, non-resolved null test, idempotency behaviour test

Existing bad data note: rows where resolvedVerdict was already set before this migration receive resolvedAt = createdAt as a best-effort backfill. Exact resolution timestamps were not stored previously. Centralising all resolve paths into a single method is recommended as a follow-up (out of scope for medium-complexity budget).

…igiNodes#219, BE-219)

- Add resolvedAt nullable timestamp column to Claim entity
- Add migration 1769600000000-AddClaimResolvedAt with backfill for
  existing resolved rows (resolvedAt = createdAt as conservative approx)
- Add claim-resolution.invariant.ts with assertResolvedAtInvariant(),
  buildResolvedFields(), buildUnresolvedFields() helpers
- Fix ClaimsService.resolveClaim(): set resolvedAt atomically with
  resolvedVerdict via buildResolvedFields(); add invariant guard before
  save; upgrade throw to NotFoundException
- Fix ClaimResolutionService.resolveClaim(): same atomic set + guard
- Fix JobsService.computeScores() (automated/oracle path): use
  buildResolvedFields() so resolvedAt is set on the job-driven path
- Remove duplicate findOne() override in ClaimsService that shadowed
  the null-returning implementation with a throwing one
- Update ClaimFactory: default resolvedAt to null; fix
  createClaimWithVerdict() to set resolvedAt alongside resolvedVerdict
- Add claim-resolution.invariant.spec.ts: full invariant unit tests
- Expand claim-resolution.service.spec.ts: resolveClaim resolvedAt
  tests (timestamp set, atomic write, finalized=true, verdict mapping)
- Expand claims.service.spec.ts: resolvedAt timestamp tests, atomicity
  test, non-resolved null test, idempotency behaviour test

Existing bad data note: rows where resolvedVerdict was already set
before this migration receive resolvedAt = createdAt as a best-effort
backfill. Exact resolution timestamps were not stored previously.
Centralising all resolve paths into a single method is recommended as
a follow-up (out of scope for medium-complexity budget).
@udeachudivine-spec

Copy link
Copy Markdown
Contributor Author

hello maintainer please merge

@dDevAhmed

Copy link
Copy Markdown
Contributor

resolve conflicts @udeachudivine-spec

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants