fix: Org Unit split being assigned to incorrect users [DHIS2-18423] #19239
+174
−9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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