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

fix: Return all visible events when no program specified [TECH-1663] #15549

Merged
merged 9 commits into from
Nov 3, 2023

Conversation

muilpp
Copy link
Contributor

@muilpp muilpp commented Oct 31, 2023

When no program present in /events, we need to return everything visible to the user according to its search scope and capture scope, that means:

  • events in open or audited programs in search scope
  • events in open or audited programs in capture scope
  • events in protected or closed programs in capture scope

The changes are applied to both the new and old API.
Ticket: https://dhis2.atlassian.net/browse/TECH-1663

@muilpp muilpp marked this pull request as ready for review November 1, 2023 11:32
@muilpp muilpp requested review from enricocolasante and a team November 1, 2023 11:32
Copy link
Contributor

@enricocolasante enricocolasante left a comment

Choose a reason for hiding this comment

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

Just a style suggestion

+ " OR ou.hierarchylevel = "
+ (params.getOrgUnit().getHierarchyLevel() + 1)
+ " ) ";
mapSqlParameterSource.addValue(COLUMN_USER_UID, user.getUid());
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to move
mapSqlParameterSource.addValue(COLUMN_ORG_UNIT_PATH, params.getOrgUnit().getPath()); mapSqlParameterSource.addValue(COLUMN_USER_UID, user.getUid());

to getOrgUnitSql method and remove the addValue operation from the single methods?
It seems to me that it would simplify the code quite a bit even if we will end up with a value in the parameter source that is not used

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem with that would be that modes CAPTURE and ACCESSIBLE don't have an orgUnit in the request, so calling params.getOrgUnit().getPath() in getOrgUnitSql would result in a NPE for these two cases.

Also, there's the scheduler running tasks with a null user. Since it's a system user, we assume it will use the mode ALL, but in that case calling user.getUid() would fail too.

Copy link

sonarqubecloud bot commented Nov 3, 2023

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

Copy link

codecov bot commented Nov 3, 2023

Codecov Report

Merging #15549 (252ad18) into master (421fc21) will increase coverage by 0.00%.
Report is 2 commits behind head on master.
The diff coverage is 96.42%.

@@            Coverage Diff            @@
##             master   #15549   +/-   ##
=========================================
  Coverage     66.22%   66.22%           
- Complexity    31234    31237    +3     
=========================================
  Files          3485     3485           
  Lines        129764   129769    +5     
  Branches      15141    15141           
=========================================
+ Hits          85931    85937    +6     
+ Misses        36750    36749    -1     
  Partials       7083     7083           
Flag Coverage Δ
integration 49.77% <96.42%> (-0.01%) ⬇️
integration-h2 32.41% <0.00%> (-0.01%) ⬇️
unit 30.33% <7.14%> (+<0.01%) ⬆️

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

Files Coverage Δ
.../dxf2/deprecated/tracker/event/JdbcEventStore.java 49.42% <100.00%> (+0.13%) ⬆️
...hisp/dhis/tracker/export/event/JdbcEventStore.java 85.41% <93.33%> (+0.03%) ⬆️

... and 4 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 11ffcfd...252ad18. Read the comment docs.

@enricocolasante enricocolasante merged commit 2e9f30b into master Nov 3, 2023
18 checks passed
@enricocolasante enricocolasante deleted the TECH-1663-return-all-events-when-no-program branch November 3, 2023 09:01
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.

2 participants