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

feat: Improve TEI Performance [DHIS2-14884] #14039

Merged
merged 72 commits into from
Jun 26, 2024

Conversation

gnespolino
Copy link
Contributor

@gnespolino gnespolino commented May 25, 2023

This PR will improve TEI performance by producing a different and optimized query.
It is based on this doc:
https://docs.google.com/document/d/1tcqDoOvKLW5W3t7HNApxbV9cEcMTq6iJIwoG2tZOsD0/edit?usp=sharing

@gnespolino gnespolino added the run-api-tests This label will trigger an api-test job for the PR. label May 25, 2023
@gnespolino gnespolino marked this pull request as draft May 25, 2023 14:14
@gnespolino gnespolino changed the title feat: extract enrollment and event values from json [DHIS2-14884] feat: [WIP] extract enrollment and event values from json [DHIS2-14884] May 25, 2023
@maikelarabori maikelarabori added the run-api-analytics-tests Enables analytics e2e tests label Jun 7, 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.

I left a few comments Giuseppe.
It looks good in general, but I'm a bit concerned about the performance when the user hits the "Download" button where we don't have any pagination in place...

Also, please don't forget to add a few good e2e tests so we can have a good coverage on it.

Thanks,
Maikel


SqlRowSet rowSet = namedParameterJdbcTemplate.queryForRowSet( query.getStatement(),
new MapSqlParameterSource().addValues( query.getParams() ) );
SqlQuery forSelect = queryCreator.createForSelect();
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe is better to keep the SqlQuery as parameter, as this can be created from outside.
It's sounds strange that "find" or "count" receives a "creator component". Receiving a sql query sounds more natural and more consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but then I should pass the SqlQueryExecutor 2 different SQLQuery: one for find, one for count

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.

I left a few comments Giuseppe.
It looks good in general, but I'm a bit concerned about the performance when the user hits the "Download" button where we don't have any pagination in place...

Also, please don't forget to add a few good e2e tests so we can have a nice coverage on it.

Thanks,
Maikel

@gnespolino gnespolino force-pushed the DHIS2-14884_POC-JSON-EXTRACTOR branch from 264dded to e6046d3 Compare July 18, 2023 09:01
@codecov
Copy link

codecov bot commented Jul 18, 2023

Codecov Report

Attention: Patch coverage is 15.46961% with 153 lines in your changes are missing coverage. Please review.

Project coverage is 67.11%. Comparing base (672f399) to head (03174cd).

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #14039      +/-   ##
============================================
- Coverage     67.18%   67.11%   -0.07%     
- Complexity    32155    32159       +4     
============================================
  Files          3556     3560       +4     
  Lines        131776   131935     +159     
  Branches      15329    15340      +11     
============================================
+ Hits          88528    88546      +18     
- Misses        36063    36196     +133     
- Partials       7185     7193       +8     
Flag Coverage Δ
integration 50.14% <1.10%> (-0.07%) ⬇️
integration-h2 34.08% <1.10%> (-0.04%) ⬇️
unit 30.65% <15.46%> (-0.02%) ⬇️

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

Files Coverage Δ
...org/hisp/dhis/analytics/common/SqlQueryResult.java 50.00% <ø> (ø)
...va/org/hisp/dhis/analytics/common/query/Field.java 85.71% <100.00%> (+1.50%) ⬆️
.../context/querybuilder/DataElementQueryBuilder.java 92.85% <100.00%> (+0.17%) ⬆️
...uery/context/querybuilder/OrgUnitQueryBuilder.java 76.47% <100.00%> (+0.71%) ⬆️
...ei/query/context/querybuilder/TeiQueryBuilder.java 75.86% <100.00%> (+6.29%) ⬆️
...tics/tei/query/context/sql/RenderableSqlQuery.java 72.22% <100.00%> (+1.63%) ⬆️
...alytics/tei/query/context/sql/SqlQueryCreator.java 33.33% <ø> (ø)
...pi/src/main/java/org/hisp/dhis/util/DateUtils.java 83.00% <66.66%> (-0.25%) ⬇️
...s/common/params/dimension/DimensionIdentifier.java 75.00% <0.00%> (-2.42%) ⬇️
...lytics/common/params/dimension/DimensionParam.java 69.81% <0.00%> (-0.67%) ⬇️
... and 8 more

... and 6 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 672f399...03174cd. Read the comment docs.

@sonarcloud
Copy link

sonarcloud bot commented Jul 20, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

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

0.0% 0.0% Coverage
0.0% 0.0% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@sonarcloud
Copy link

sonarcloud bot commented Aug 21, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

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

0.0% 0.0% Coverage
0.0% 0.0% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@gnespolino gnespolino changed the title feat: [WIP] extract enrollment and event values from json [DHIS2-14884] feat: [WIP] extract enrollment and event values from json [DHIS2-14884] - long standing DONT close please Oct 30, 2023
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

class JsonExtractorUtilsTest {

Check notice

Code scanning / CodeQL

Unused classes and interfaces Note test

Unused class: JsonExtractorUtilsTest is not referenced within this codebase. If not used as an external API it should be removed.
private static final Pattern TRAILING_ZEROES = Pattern.compile("0*$");
private static final Pattern ENDING_WITH_DOT = Pattern.compile("\\.$");

public static String getFormattedDate(LocalDateTime date) {
Copy link
Contributor

@maikelarabori maikelarabori Jun 12, 2024

Choose a reason for hiding this comment

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

It would be nice to have a Javadoc here as well

@gnespolino gnespolino marked this pull request as ready for review June 12, 2024 11:39
@gnespolino gnespolino changed the title feat: [WIP] Improve TEI Performance [DHIS2-14884] feat: Improve TEI Performance [DHIS2-14884] Jun 12, 2024
Copy link

sonarcloud bot commented Jun 25, 2024

@gnespolino gnespolino merged commit 100eb77 into master Jun 26, 2024
15 checks passed
@gnespolino gnespolino deleted the DHIS2-14884_POC-JSON-EXTRACTOR branch June 26, 2024 15:10
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 run-api-tests This label will trigger an api-test job for the PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants