Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analytics API: Add support for Option in /analytics [DHIS2-18368] #19558

Merged
merged 57 commits into from
Feb 12, 2025

Conversation

d-bernat
Copy link
Contributor

@d-bernat d-bernat commented Dec 23, 2024

As part of the option set and options feature, we need to change the /analytics API to support the following style of queries related to OptionSet and Option.

The changes are only required for Program Attributes and Program Data Elements, where two new models were created to extend the existing flow and logic.

  • Examples of requests enabled with these changes:
http://localhost:8080/dhis/api/analytics?dimension=pe:LAST_10_YEARS&filter=ou:USER_ORGUNIT&dimension=dx:WSGAb5XwJ3Y.QFX1FLWBwtq.l8S7SjnQ58G;WSGAb5XwJ3Y.QFX1FLWBwtq.rexqxNDqUKg;M3xtLkYBlKI.KrCahWFMYYz.dEFhuheLj1A&displayProperty=NAME&includeNumDen=true&skipMeta=false&skipData=false&includeMetadataDetails=true&relativePeriodDate=2025-07-01

http://localhost:8080/dhis/api/analytics?dimension=dx:M3xtLkYBlKI.KrCahWFMYYz.dEFhuheLj1A;M3xtLkYBlKI.KrCahWFMYYz.HrKHCQUSYZh,pe:LAST_10_YEARS&filter=ou:USER_ORGUNIT&displayProperty=NAME&includeNumDen=true&skipMeta=false&skipData=false&relativePeriodDate=2025-07-01

http://localhost:8080/dhis/api/analytics?dimension=pe:LAST_10_YEARS&filter=ou:USER_ORGUNIT&filter=dx:WSGAb5XwJ3Y.QFX1FLWBwtq.l8S7SjnQ58G;WSGAb5XwJ3Y.QFX1FLWBwtq.rexqxNDqUKg&displayProperty=NAME&includeNumDen=true&skipMeta=false&skipData=false&includeMetadataDetails=true&relativePeriodDate=2025-07-01

New analytics end-to-end tests are also included, so we can ensure the new feature is well covered.
The metadata was also modified to accommodate the new dimension.

Finally, very light clean-up and specific refactoring were applied where it made sense, especially to respect our Sonar rules.

@d-bernat d-bernat changed the title 2.42 dhis2 18368 3 Analytics API: Add Options aggregation and disaggregation[2.42-DHIS2-18368_3] Dec 23, 2024
@d-bernat d-bernat added the run-api-analytics-tests Enables analytics e2e tests label Dec 23, 2024
@maikelarabori maikelarabori changed the title Analytics API: Add Options aggregation and disaggregation[2.42-DHIS2-18368_3] Analytics API: Add support for Option in /analytics [DHIS2-18368] Feb 7, 2025
@maikelarabori maikelarabori marked this pull request as ready for review February 7, 2025 13:58
Copy link
Contributor

@luciano-fiandesio luciano-fiandesio left a comment

Choose a reason for hiding this comment

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

Looks good, just left a couple of minor comments.

@@ -78,17 +78,18 @@ public ProgramTrackedEntityAttributeOptionDimensionItem(

@Override
public String getName() {
return joinWith(
SPACE, program.getDisplayName(), attribute.getDisplayName(), option.getDisplayName());
return format(
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to add some null checks here (in the constructor), something like:

public ProgramTrackedEntityAttributeOptionDimensionItem(
      Program program, TrackedEntityAttribute attribute, Option option) {
    this.program = Objects.requireNonNull(program, "Program cannot be null");
        this.attribute = Objects.requireNonNull(attribute, "Attribute cannot be null");
        this.option = Objects.requireNonNull(option, "Option cannot be null");
  }

@maikelarabori maikelarabori self-requested a review February 12, 2025 09:54
@maikelarabori maikelarabori merged commit 1fc9f97 into master Feb 12, 2025
17 checks passed
@maikelarabori maikelarabori deleted the 2.42-DHIS2-18368_3 branch February 12, 2025 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-api-analytics-tests Enables analytics e2e tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants