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

Fixed #15005 - Improvements on user merge #15016

Merged
merged 19 commits into from
Jul 3, 2024
Merged

Fixed #15005 - Improvements on user merge #15016

merged 19 commits into from
Jul 3, 2024

Conversation

snipe
Copy link
Owner

@snipe snipe commented Jul 3, 2024

Okay, this should tweak the way the merging works in both the UI and the merge user script to do the following:

  1. Change the user ID of uploaded files to the user being merged into
  2. Change the user ID of any acceptances that might apply
  3. Added a buttload of tests
  4. Added the event listener for merges to the artisan command as well

The cli and the UI do slightly different things. The UI lets you select two or more users and select which one you want to merge the other(s) into. This is not so much a bulk thing, since if you accidentally duped 10k users, that would take a while, but it's handy for smaller numbers of mistakes, like if a person's name changed in SCIM/LDAP but it wasn't changed in Snipe-IT, so it ended up creating a new user.

The cli version is more for people who messed up their LDAP setup by not renaming all of their users to have usernames that are an email address before initiating LDAP or SCIM, thus duplicating their users. Sometimes people didn't realize that even happened, so both versions of the user could have things checked out to them, so we have to merge the two into one and delete the other.

That artisan command aims to look for all users that don't have an email formatted like an email address and tries to find the user that does have a user formatted as an email address to merge into.

This should also fix #15005

Copy link

what-the-diff bot commented Jul 3, 2024

PR Summary

  • Enhancements to BulkUsersController
    This update improves the way we merge user information. New relationships for uploads and acceptances have been introduced to ensure more thorough and reliable merging, and better updating of certain fields in userlog, uploads, and acceptances tables.

  • Updates to User Model
    Further establishing our user system, we have put into effect an acceptances relationship within our User Model. This allows us better manage how user actions intersect with user acceptances.

  • Expansion of ActionlogFactory
    To provide more varied testing methods, we added two methods: filesUploaded() and acceptedSignature(). These methods will simulate situations where files are uploaded or signatures are accepted.

  • User Merging Fully Tested
    A series of test cases have been introduced in MergeUserTest. These tests comprehensively assess the transfer of assets, files, and acceptances when merging users. This integration substantially improves our testing coverage, ensuring that our user merging process is robust and efficient.

snipe added 2 commits July 3, 2024 14:32
Signed-off-by: snipe <[email protected]>
Signed-off-by: snipe <[email protected]>
@snipe snipe changed the title WIP - Fixed #15005 - Improved user merge WIP - Fixed #15005 - Improvements on user merge Jul 3, 2024
@snipe snipe changed the title WIP - Fixed #15005 - Improvements on user merge Fixed #15005 - Improvements on user merge Jul 3, 2024
@snipe snipe requested review from marcusmoore and uberbrady July 3, 2024 19:55
Signed-off-by: snipe <[email protected]>
Copy link
Collaborator

@uberbrady uberbrady left a comment

Choose a reason for hiding this comment

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

This looks amazingly thorough - and thanks, also for the new Console script test! This is the type of thing that gives me confidence that we can make changes to this functionality and know that it's very unlikely to break. Nice work!

Copy link
Collaborator

@marcusmoore marcusmoore left a comment

Choose a reason for hiding this comment

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

Tests! 😄

Two things that should probably be changed and then a ton of nitpicks 😬

Other than that this looks good 😄

});
}

public function logUserUpdate()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nitpick: this would read better in the past tense like the other methods you added. Maybe userUpdated()

Copy link
Owner Author

Choose a reason for hiding this comment

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

I actually disagree on this. Since it's in the ActionLog factory, I sorta feel like it's more explicit this way, but it's not a hill I'll die on.

database/factories/ConsumableFactory.php Outdated Show resolved Hide resolved
tests/Feature/Console/MergeUsersTest.php Outdated Show resolved Hide resolved
tests/Feature/Console/MergeUsersTest.php Outdated Show resolved Hide resolved
tests/Feature/Console/MergeUsersTest.php Outdated Show resolved Hide resolved
tests/Feature/Console/MergeUsersTest.php Outdated Show resolved Hide resolved
tests/Feature/Console/MergeUsersTest.php Outdated Show resolved Hide resolved
tests/Feature/Console/MergeUsersTest.php Outdated Show resolved Hide resolved
tests/Feature/Console/MergeUsersTest.php Outdated Show resolved Hide resolved
tests/Feature/Users/Ui/MergeUsersTest.php Outdated Show resolved Hide resolved
Signed-off-by: snipe <[email protected]>
@snipe snipe requested a review from marcusmoore July 3, 2024 22:02
Signed-off-by: snipe <[email protected]>
Signed-off-by: snipe <[email protected]>
@snipe snipe merged commit a6d0450 into develop Jul 3, 2024
8 of 9 checks passed
@snipe snipe deleted the improved_user_merge branch July 3, 2024 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants