-
Notifications
You must be signed in to change notification settings - Fork 352
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: Org Unit split being assigned to incorrect users [DHIS2-18423] #19239
base: master
Are you sure you want to change the base?
Conversation
Quality Gate passedIssues Measures |
@@ -224,4 +226,15 @@ Map<String, Optional<Locale>> findNotifiableUsersWithPasswordLastUpdatedBetween( | |||
User getUserByVerificationToken(String token); | |||
|
|||
User getUserByVerifiedEmail(String email); | |||
|
|||
/** | |||
* Method that retrieves all {@link User}s that have an entry for the {@link OrganisationUnit} in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps not use "Method that" in method Javadoc, as it is implicit.
* WARNING: If this field has an empty collection, it can potentially result in all users being | ||
* returned from the database. Check the generated query to make sure you're seeing expected | ||
* queries and results. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this phrasing is a bit misleading. This is one of many potential filters that when empty does not filter away anything. That sounds like expected behaviour to me as long as it is clear that empty means "not set" and not "match against an empty set". I think the comment we leave here should make that clear.
* @param uid {@link OrganisationUnit} {@link UID} to match on | ||
* @return matching {@link User}s | ||
*/ | ||
List<User> getUsersWithOrgUnit(@Nonnull String orgUnitTable, @Nonnull UID uid); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should have names of tables escape the store. That is one of the main points to have a store abstraction. Maybe use an enum?
While these 3 properties are backed by mapping tables in the DB in the object model these are properties so the wording should be accordingly.
Issue
Org Unit split feature is assigning the split org units to incorrect users (sometimes all the users in the DB in certain circumstances)
Cause
After creating the
UserQueryParams
with the sourceOrganisationUnit
, thatOrganisationUnit
was being overridden to use theUser
'sOrganisationUnit
s carrying out the split.In cases where the
User
either had noorganisationUnits
,dataViewOrganisationUnits
, orteiSearchOrganisationUnits
, then all theUser
s in the DB would be returned from the query, resulting in allUser
s getting the splitOrganisationUnit
s.Fix avoids using:
UserService#handleUserQueryParams
which was overriding the sourceOrganisationUnit
already setUserStore#getUsers
which tries to generate a handcrafted SQL query taking into consideration a multitude of options & checks usingUserQueryParams
(this looks too complex and tries to accommodate too many things). This resulted in returning allUser
s in the DBFix
Use a dedicated query to fetch the
User
s to be actioned.Fewer select queries are generated as a result of the fix, and is not proportionate to the number of users found (old query was triggering 1 extra query per user found - manual testing).
Warning added to
UserQueryParams
property.Testing
Automated
2 integration tests added