Skip to content

fix: Order event consistent way [DHIS2-20814] - #173

Merged
enricocolasante merged 2 commits into
masterfrom
DHIS2-20814
Feb 12, 2026
Merged

enricocolasante merged 2 commits into
masterfrom
DHIS2-20814

Conversation

@enricocolasante

@enricocolasante enricocolasante commented Feb 5, 2026 •

Copy link
Copy Markdown
Contributor
  • Change RuleEvent.eventDate type from RuleInstant to RuleLocalDate to correctly model event dates as calendar dates rather than timestamps
  • Add createdAtClientDate field to RuleEvent
  • Implement Comparable<RuleEvent> to provide consistent event ordering: primary sort by eventDate, secondary sort by createdAtClientDate (falling back to createdDate)
  • Expose a new RuleEngine.order() API method for consumers to sort events
  • Bump version to 3.6.0-SNAPSHOT (breaking API changes)

Breaking changes

  • RuleEvent.eventDate is now RuleLocalDate instead of RuleInstant
  • RuleEvent constructor has a new required field createdAtClientDate: RuleInstant?

@enricocolasante
enricocolasante force-pushed the DHIS2-20814 branch 4 times, most recently from a5043d4 to 4a6ee83 Compare February 9, 2026 09:02
@enricocolasante
enricocolasante marked this pull request as ready for review February 9, 2026 09:05

@vgarciabnz vgarciabnz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The function orderEvents() is not exposed in the JS artifact. This method uses RuleEvent, which is not exposed either, so this function cannot be annotated with @JsExport directly. It would need a different function for JS.

val dataValues: List<RuleDataValue>,
)
): Comparable<RuleEvent> {
val resolvedCreatedDate get() = (createdAtClientDate ?: createdDate).instant

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This variable name looks like a name that could be internal. If you want to make it internal, you can add the modifier internal at the start of the line.

@vgarciabnz vgarciabnz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good!

@zubaira zubaira left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Will it also order scheduled events ? ( events when eventDate is null )

@zubaira
zubaira self-requested a review February 12, 2026 07:44

@zubaira zubaira left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@enricocolasante

Copy link
Copy Markdown
Contributor Author

Will it also order scheduled events ? ( events when eventDate is null )

EventDate cannot be null in RuleEvent. For scheduled events, we are using scheduled date to populate eventDate for RuleEvent

@enricocolasante
enricocolasante merged commit 25e9b73 into master Feb 12, 2026
2 checks passed
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.

3 participants