[MDS-6764] - NRIS duplicate entries#3807
Merged
matbusby-fw merged 1 commit intodevelopfrom Jan 27, 2026
Merged
Conversation
…ess. - Implemented counters for processed, missing, and deleted assessments. - Added logic to avoid creation of duplicate database entities. - Enhanced data cleanliness by resetting relational fields prior to updates. - Improved log output to include ETL processing summaries for better traceability.
matbusby-fw
commented
Jan 26, 2026
| inspection = Inspection(external_id=_parse_element_text(assessment_id)) | ||
| # Find or create the inspection | ||
| inspection = db.session.query(Inspection).filter_by(external_id=external_id).first() | ||
| if inspection is None: |
Collaborator
Author
There was a problem hiding this comment.
This is the core of the change. Checking for an inspection within the session that already contains the external_id and updating it if necessary. The rest of the changes generally follow on this behaviour to ensure idempotency.
alva-fresh
approved these changes
Jan 26, 2026
simensma-fresh
approved these changes
Jan 26, 2026
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.
Our NRIS api was creating multiple records from the raw data with new internal ids, but the same external one which shouldn't happen. Updated it to ensure idempotency of the records.
Objective
MDS-6764
Why are you making this change? Provide a short explanation and/or screenshots