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

Merge complex institutions with overlapping users #3331

Merged
merged 13 commits into from
Feb 3, 2022

Conversation

jorg-vr
Copy link
Contributor

@jorg-vr jorg-vr commented Jan 28, 2022

This pull request builds upon #3327 but is split off to keep the individual pull request manageable.

It introduces an interactive script to merge two institution who potentially have overlapping users. It uses the merge_users interactive script to merge the overlapping users first.

This all happens in a single transaction, as both the merge of users and that of institutions depend on each other.

Because of this transactional nature I had to introduce a new gem after_commit_everywhere
This gem makes sure certain side effects are only applied after the full transaction is successfully committed.

See the test The script should also rollback filesystem changes for a test case that was broken without this gem.

Peek 2022-01-31 16-59

The relevant command is printed in the error message when merging institutions using the web interface has failed
image

  • Tests were added

@jorg-vr jorg-vr added the feature New feature or request label Jan 28, 2022
@jorg-vr jorg-vr self-assigned this Jan 28, 2022
@jorg-vr jorg-vr requested a review from a team as a code owner January 28, 2022 13:29
@jorg-vr jorg-vr requested review from bmesuere and chvp and removed request for a team January 28, 2022 13:29
@jorg-vr jorg-vr marked this pull request as draft January 28, 2022 13:29
@jorg-vr jorg-vr marked this pull request as ready for review January 31, 2022 16:11
Copy link
Member

@bmesuere bmesuere left a comment

Choose a reason for hiding this comment

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

Right now, we already offer an institution merge on the website but this sometimes fails due to overlapping users. Since this PR provides a way to merge these institutions semi-automatically, it would be nice if the command that is needed for this is printed along with the error message that is shown when the automatic merge fails.

I'm thinking about a way on how to test this with actual data without risking data loss. The only way I can think of is copying some problematic data from the production environment to naos but this might be a lot of work (this is why #2866 would be nice).

The code itself looks ok.

app/models/submission.rb Show resolved Hide resolved
Base automatically changed from feature/2668-merge-users-console to develop February 1, 2022 15:40
@jorg-vr jorg-vr requested a review from bmesuere February 1, 2022 16:15
app/runners/merge_institutions.rb Outdated Show resolved Hide resolved
@jorg-vr jorg-vr requested a review from chvp February 3, 2022 08:48
Copy link
Member

@bmesuere bmesuere left a comment

Choose a reason for hiding this comment

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

Looking forward to merge some problematic institutions :)

@jorg-vr jorg-vr merged commit c42c764 into develop Feb 3, 2022
@jorg-vr jorg-vr deleted the feature/merge_complex_institutions branch February 3, 2022 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants