Add general-purpose script for deleting dangling data values#583
Closed
Ramon-Jimenez wants to merge 1 commit intodevelopmentfrom
Closed
Add general-purpose script for deleting dangling data values#583Ramon-Jimenez wants to merge 1 commit intodevelopmentfrom
Ramon-Jimenez wants to merge 1 commit intodevelopmentfrom
Conversation
Replaces the old delete-wrong-data-values.ts script which was hardcoded
to a specific instance and COVID-specific category combos.
The new script reuses ProjectDb.getDanglingDataValues() to detect
orphaned data values across all projects (or a specific one), writes
a review report, and allows deletion via the DHIS2 API.
Usage:
yarn ts-node src/scripts/delete-dangling-data-values.ts \
--url=DHIS2URL --generate [--project=ID]
yarn ts-node src/scripts/delete-dangling-data-values.ts \
--url=DHIS2URL --post
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
BundleMonNo change in files bundle size Unchanged groups (1)
Final result: ✅ View report in BundleMon website ➡️ |
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.
Summary
delete-dangling-data-values.tsscript that replaces the olddelete-wrong-data-values.ts, which was hardcoded to a specific DHIS2 instance and COVID-specific category combos.ProjectDb.getDanglingDataValues()detection logic, which identifies data values whose(dataElement, categoryOptionCombo)pair no longer matches the project's current configuration.--project=ID.--generatewrites a report + delete payload for review,--postexecutes the deletion.Usage
Context
A client reported that after removing and re-adding an indicator from a project, "dangling" data values remained in the DHIS2 database. These orphaned values were still visible in their Tableau extracts from the DHIS2 PostgreSQL. The app already detects and notifies about dangling data (via
ProjectNotification), but had no general-purpose tool to clean them up.Test plan
--generateagainst a test DHIS2 instance and verify the report is accurate--postand verify dangling values are removed from DHIS2🤖 Generated with Claude Code