Skip to content

OCLOMRS-1123: Add a configurable task to clean-up old import records#123

Draft
ibacher wants to merge 2 commits intomasterfrom
OCLOMRS-1123
Draft

OCLOMRS-1123: Add a configurable task to clean-up old import records#123
ibacher wants to merge 2 commits intomasterfrom
OCLOMRS-1123

Conversation

@ibacher
Copy link
Copy Markdown
Member

@ibacher ibacher commented Apr 2, 2026

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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 debounced CleanupScheduler that 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.

Comment thread api/src/main/resources/moduleApplicationContext.xml
Comment thread omod/src/main/resources/config.xml Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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