Skip to content

[DT-4263][3/7] Add DAR codes and DUOS-IDs to email sends - #3147

Open
kevinmarete wants to merge 2 commits into
km-dt-4263-email-sendsfrom
km-dt-4263-email-dar-dataset-ids
Open

kevinmarete wants to merge 2 commits into
km-dt-4263-email-sendsfrom
km-dt-4263-email-dar-dataset-ids

Conversation

@kevinmarete

@kevinmarete kevinmarete commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Addresses

https://broadworkbench.atlassian.net/browse/DT-4263

Security risk: low — adds DAR codes and dataset IDs to an admin-only read endpoint; both are already visible to admins elsewhere.

Summary

Stacked on #3142. Each send from GET /api/mail/sends now carries darCode and datasetIdentifiers, for the Email Log's DAR-ID and DUOS-ID columns agreed on DT-4084 (one dataset shows its ID, several show "Multiple").

email_entity.entity_reference_id holds a different thing per email type. The new EmailReference enum records which, in an exhaustive switch over EmailType, so a new email type doesn't compile until it's classified:

Stored reference Types DAR code DUOS-IDs
DAR code NEW_DAR, NEW_CASE, approvals itself the submitted DAR's datasets, not its progress reports'
DAR or progress report id SO, expiry, closeout, RADAR the row's collection; a progress report shares its parent's that row's datasets
Election id REMINDER the election's DAR the election's dataset, else the DAR's
DUOS-ID / dataset name dataset approved/denied, NEW_DATASET — that dataset

Other types (digests, DAA, library card, study emails) come back with no DAR code and no datasets. #3148 narrows approval and progress-report emails and adds study emails.

  • EmailReference reaches the query as one kinds list indexed by email type number (kinds[email_type]), not one list per kind, so the lists can't be passed in the wrong order.
  • Older rows that stored a different kind of reference are read as what they hold: a DAR reference id on a DAR-code type, a DAR code on a reference-id type (DAR_EXPIRED did briefly in 2025), and a dataset name on DATASET_APPROVED/DENIED, which stored names until 2026.
  • The query returns dataset aliases and the mapper formats them with Dataset.parseAliasToIdentifier, so the DUOS-ID format has one definition.
  • The lookups run after paging, so only the page's sends are looked up.
  • Datasets are read as they are now, not when the email was sent: nothing records them at send time.

Reading the query

The CTEs up to sends are #3142's. The final SELECT joins each send to dar_collection by code, to election by id, then to data_access_request by reference id (or the election's DAR), and the LATERAL subquery collects dataset aliases from whichever of those matched.

Example: a REMINDER whose reference is 42 joins election 42, reaches its DAR through election.reference_id, takes darCode from that DAR's collection, and returns election 42's dataset as the one DUOS-ID.


Have you read CONTRIBUTING.md lately? If not, do that first.

  • Label PR with a Jira ticket number and include a link to the ticket
  • Label PR with a security risk modifier [no, low, medium, high]
  • PR describes scope of changes
  • Get a minimum of one thumbs worth of review, preferably two if enough team members are available
  • Get PO sign-off for all non-trivial UI or workflow changes
  • Verify all tests go green
  • Test this change deployed correctly and works on dev environment after deployment

🤖 Generated with Claude Code

@kevinmarete
kevinmarete force-pushed the km-dt-4263-email-dar-dataset-ids branch from 78e904c to d1c6131 Compare October 9, 2026 22:11
@kevinmarete kevinmarete self-assigned this Oct 9, 2026
@kevinmarete
kevinmarete force-pushed the km-dt-4263-email-dar-dataset-ids branch 2 times, most recently from b1886dd to f51c862 Compare October 10, 2026 00:27
@kevinmarete kevinmarete changed the title [DT-4263][2/3] Add DAR codes and DUOS-IDs to email sends [DT-4263][2/4] Add DAR codes and DUOS-IDs to email sends Oct 10, 2026
@kevinmarete
kevinmarete force-pushed the km-dt-4263-email-dar-dataset-ids branch from f51c862 to 922b9e2 Compare October 10, 2026 00:52
@kevinmarete
kevinmarete force-pushed the km-dt-4263-email-sends branch from 162bef3 to 7617930 Compare October 10, 2026 01:09
@kevinmarete
kevinmarete force-pushed the km-dt-4263-email-dar-dataset-ids branch from 922b9e2 to 7b4ebf7 Compare October 10, 2026 01:11
@kevinmarete
kevinmarete force-pushed the km-dt-4263-email-sends branch from 7617930 to 083c4ad Compare October 10, 2026 01:22
@kevinmarete
kevinmarete force-pushed the km-dt-4263-email-dar-dataset-ids branch 2 times, most recently from 8945635 to 4e38d8c Compare October 10, 2026 01:58
kevinmarete and others added 2 commits October 9, 2026 23:25
Each send now carries the DAR code and the DUOS-IDs of the datasets it
concerns, read from its entity reference according to what its email
type stores there. EmailReference records that for every email type in
an exhaustive switch, so a new type must be classified before it
compiles, and the query receives it as one array indexed by type.
Older rows that stored a different kind of reference (a DAR reference
id on a DAR-code type, a DAR code on a reference-id type, a dataset
name on a DUOS-ID type) are read as what they hold.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dataset.alias is bigint where Liquibase created it but numeric on
databases older than that changeset, such as the dev copy, which made
the mapper's Long[] cast throw.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kevinmarete
kevinmarete force-pushed the km-dt-4263-email-dar-dataset-ids branch from ba208a2 to 1b6c635 Compare October 10, 2026 03:25
@kevinmarete
kevinmarete marked this pull request as ready for review October 10, 2026 05:05
@kevinmarete
kevinmarete requested a review from a team as a code owner October 10, 2026 05:05
@kevinmarete
kevinmarete requested review from fboulnois, otchet-broad and rushtong and removed request for a team October 10, 2026 05:05
@kevinmarete kevinmarete changed the title [DT-4263][2/4] Add DAR codes and DUOS-IDs to email sends [DT-4263][3/7] Add DAR codes and DUOS-IDs to email sends Oct 10, 2026
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.

1 participant