fix: Investigate the reason of differences in events x enrollments in analytics query[2.39-DHIS2-16227-backport] #17750
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.
Backport
There is the problem with sorting of the repeatable stages. The issue was pinpointed to the event report date in the repeatable stage. The capture app allowed users to add new events in the repeatable stage. The report date (found in the executiondate column of the event table in the tracker database) is treated as a date without a time section. When analytics queries for repeatable stage events using an position index, the executiondate is crucial for ensuring the correct outcome, as it serves as the sorting criteria. Sorting on non-unique data can yield inconsistent results. This is the scenario described in the ticket. Report dates of events within the repeatable stage are not unique, and sorting may yield different outcomes.