fix: Only use occurreddate to filter events in exporter [DHIS2-17732] #19363
+6
−21
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.
We were applying some magic between
occurreddate
andscheduleddate
in events and it was creating a performance issue and some odd behavior.Performance issue
occurreddate
, if there was a null value, then the one inscheduledate
was used. This behavior was preventing the index onoccurreddate
to be used by the query planner slowing down the query performance.Odd behavior
occurredAfter
andoccurredBefore
are used to filter theoccurreddate
but because of the logic that we had in the query, null values ofoccurreddate
could be part of the result.scheduleddate
withoccurreddate
value if the former one was null. This wrongly appears as if the event was once scheduled and occurred in the same point in time. If an event was never scheduled, it should have a nullscheduleddate
.These corner cases were not tested so no test is breaking. The feature itself is already properly tested in https://github.com/dhis2/dhis2-core/blob/master/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/export/event/EventExporterTest.java