OCLOMRS-1123: Add a configurable task to clean-up old import records#123
Draft
OCLOMRS-1123: Add a configurable task to clean-up old import records#123
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a configurable post-import cleanup mechanism to remove older import items/import records while preserving at least one non-error item per OCL URL to keep URL-based lookups functional.
Changes:
- Introduces new global properties to configure cleanup retention policy (RUNS/DAYS) and debounce delay.
- Adds
ItemCleanupService+ implementation and a debouncedCleanupSchedulerthat runs cleanup after imports complete. - Adds unit/integration tests covering scheduler debounce/delay behavior and cleanup retention rules.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
omod/src/main/resources/config.xml |
Adds cleanup-related global properties (retention type/value and delay). |
api/src/main/resources/moduleApplicationContext.xml |
Wires the cleanup service, task scheduler, and injects the cleanup scheduler into the importer. |
api/src/main/java/org/openmrs/module/openconceptlab/scheduler/CleanupScheduler.java |
Implements debounced scheduling and daemon-thread execution with a retry. |
api/src/main/java/org/openmrs/module/openconceptlab/ItemCleanupService.java |
Defines the cleanup service API with authorization. |
api/src/main/java/org/openmrs/module/openconceptlab/ItemCleanupServiceImpl.java |
Implements retention-policy evaluation, preserves latest per URL, batch-deletes items, and deletes orphaned imports. |
api/src/main/java/org/openmrs/module/openconceptlab/OpenConceptLabConstants.java |
Adds constants for new cleanup global property keys. |
api/src/main/java/org/openmrs/module/openconceptlab/importer/Importer.java |
Schedules cleanup after stopping an import. |
api/src/test/java/org/openmrs/module/openconceptlab/scheduler/CleanupSchedulerTest.java |
Tests cleanup scheduling delay and debounce cancellation behavior. |
api/src/test/java/org/openmrs/module/openconceptlab/ItemCleanupServiceTest.java |
Adds coverage for retention policies and preservation guarantees. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
The goal here is to add a clean-up task that removes old imports in a somewhat configurable way. Basically, via GP, it's possible to specify a number of days or a number of runs that should be preserved.
Regardless, the clean-up will preserve at least one non-errored item for each URL so that the lookup via OCL URLs will continue to work.
This is a draft because it needs some testing and some clean-up.