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

Metadata for user orgunits in analytics response [2.41-dhis2-15933] #15451

Merged
merged 30 commits into from
Oct 24, 2023

Conversation

d-bernat
Copy link
Contributor

@d-bernat d-bernat added the run-api-analytics-tests Enables analytics e2e tests label Oct 23, 2023
@codecov
Copy link

codecov bot commented Oct 23, 2023

Codecov Report

Merging #15451 (6f2031a) into master (ada6f8a) will increase coverage by 0.02%.
Report is 5 commits behind head on master.
The diff coverage is 92.04%.

@@             Coverage Diff              @@
##             master   #15451      +/-   ##
============================================
+ Coverage     66.10%   66.13%   +0.02%     
- Complexity    31115    31138      +23     
============================================
  Files          3484     3486       +2     
  Lines        129448   129525      +77     
  Branches      15095    15104       +9     
============================================
+ Hits          85577    85655      +78     
+ Misses        36792    36788       -4     
- Partials       7079     7082       +3     
Flag Coverage Δ
integration 49.69% <39.77%> (-0.02%) ⬇️
integration-h2 32.47% <34.09%> (+0.02%) ⬆️
unit 30.33% <85.22%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
.../org/hisp/dhis/analytics/AnalyticsMetaDataKey.java 100.00% <100.00%> (ø)
...in/java/org/hisp/dhis/common/DataQueryRequest.java 61.68% <100.00%> (+0.72%) ⬆️
.../java/org/hisp/dhis/analytics/DataQueryParams.java 80.75% <100.00%> (+0.10%) ⬆️
...p/dhis/analytics/data/DefaultDataQueryService.java 81.33% <100.00%> (+0.12%) ⬆️
...p/dhis/analytics/data/handler/MetadataHandler.java 68.08% <100.00%> (+2.96%) ⬆️
...rg/hisp/dhis/analytics/event/EventQueryParams.java 78.93% <100.00%> (+0.17%) ⬆️
.../event/data/DefaultEnrollmentAnalyticsService.java 75.00% <100.00%> (ø)
...ytics/event/data/DefaultEventAnalyticsService.java 32.43% <100.00%> (ø)
...ytics/event/data/DefaultEventDataQueryService.java 84.55% <100.00%> (+0.05%) ⬆️
...va/org/hisp/dhis/common/EventDataQueryRequest.java 69.69% <66.66%> (-0.06%) ⬇️
... and 3 more

... and 15 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8ed6fd5...6f2031a. Read the comment docs.

import org.hisp.dhis.common.EventsAnalyticsQueryCriteria;
import org.junit.jupiter.api.Test;

class OrganisationUnitCriteriaUtilsTest {

Check notice

Code scanning / CodeQL

Unused classes and interfaces Note test

Unused class: OrganisationUnitCriteriaUtilsTest is not referenced within this codebase. If not used as an external API it should be removed.
@d-bernat d-bernat changed the title DRAFT: Metadata for user orgunits in analytics response [2.41-dhis2-15933] Metadata for user orgunits in analytics response [2.41-dhis2-15933] Oct 24, 2023
Copy link
Contributor

@maikelarabori maikelarabori left a comment

Choose a reason for hiding this comment

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

Added a few suggestions 👍
Also, this same logic should be applied to the TEI/Cross Program API (I believe). The UI requests are built using the same components and are read on the same page.

}

/**
* Transform criteria in the string
Copy link
Contributor

Choose a reason for hiding this comment

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

What does it mean ("Transform criteria in the string")?
Would be nice to describe what the method actually does, including an example of a possible output.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

: StringUtils.EMPTY;
}

private static boolean hasDimensions(Set<String> dimensions) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need to create this additional method...
You could use CollectionUtils.isNotEmpty(criteria.getDimension())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

currentUserService.getCurrentUser(), params.getUserOrganisationUnitsCriteria())
.forEach(items::putAll);

if (params.isComingFromQuery()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we concentrate all the logic of the if/else related to

params.isComingFromQuery()

on the same block? ie:

      if (params.isComingFromQuery()) {
        items.putAll(getMetadataItems(params, periodKeywords, optionItems, grid));
        metadata.put(
            DIMENSIONS.getKey(), getDimensionItems(params, Optional.of(optionsPresentInGrid)));
      } else {
        items.putAll(getMetadataItems(params));
        metadata.put(DIMENSIONS.getKey(), getDimensionItems(params, empty()));
      }

      metadata.put(ITEMS.getKey(), items);

Or is it going to have a side affect?

Copy link
Contributor Author

@d-bernat d-bernat Oct 24, 2023

Choose a reason for hiding this comment

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

The items will change the place with dimensions. I thing this should not be a problem, should I change it?
Do not forget, it will affect most likely our e2e tests and som unit tests as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

So, it may have a side effect. We never know if someone is relying on this order.
Let's leave it for now.

d-bernat and others added 8 commits October 24, 2023 11:28
…hisp/dhis/analytics/util/AnalyticsOrganisationUnitUtils.java

Co-authored-by: Maikel Arabori <[email protected]>
…hisp/dhis/analytics/util/AnalyticsOrganisationUnitUtils.java

Co-authored-by: Maikel Arabori <[email protected]>
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

currentUserService.getCurrentUser(), params.getUserOrganisationUnitsCriteria())
.forEach(items::putAll);

if (params.isComingFromQuery()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

So, it may have a side effect. We never know if someone is relying on this order.
Let's leave it for now.

* Transform request criteria into a comma separated string
* (USER_ORG_UNIT,USER_ORGUNIT_CHILDREN,USER_ORGUNIT_GRANDCHILDREN)
*
* @param dimensions, set of the requested dimensions

Check notice

Code scanning / CodeQL

Spurious Javadoc @param tags Note

@param tag "dimensions," does not match any actual parameter of method "getAnalyticsQueryCriteria()".
@d-bernat d-bernat merged commit 95b7afe into master Oct 24, 2023
18 checks passed
@d-bernat d-bernat deleted the 2.41-DHIS2-15933 branch October 24, 2023 10:41
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