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 accounts #1683

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7533775
merge simple attributes
fherreazcue Nov 20, 2023
92fc04a
destroy other person after merge
fherreazcue Nov 21, 2023
beb336d
merge group_memberships (work_groups and projects)
fherreazcue Nov 21, 2023
8a5f37c
Guard 'destroy' and back-up other person's details in tests before de…
fherreazcue Nov 21, 2023
c58e87b
merge annotations
fherreazcue Nov 21, 2023
7a90b11
Programmes and institutions also covered by group_memberships
fherreazcue Nov 23, 2023
525d8f1
check not merging empty arrays
fherreazcue Nov 23, 2023
c43cdae
merge subscriptions
fherreazcue Nov 24, 2023
a34e8c0
Merge resources (contributor and creator)
fherreazcue Nov 24, 2023
1daacd7
Merge permissions
fherreazcue Nov 24, 2023
f0b8dbf
Merge roles
fherreazcue Nov 27, 2023
4802091
Refactor merge_associations
fherreazcue Nov 28, 2023
5e1f0c9
Merge user
fherreazcue Nov 28, 2023
7a34d00
Adds activity log
fherreazcue Nov 28, 2023
9f7ce4c
rubocop
fherreazcue Nov 28, 2023
ec4c515
Person.transaction wraps all
fherreazcue Nov 28, 2023
003c0ce
Use send instead of constantize
fherreazcue Nov 28, 2023
ebb6463
Use in_batches for update_all or destroy_all.
fherreazcue Nov 29, 2023
40fcf76
merge_user also interrupted if no other_person.user
fherreazcue Nov 29, 2023
8d64fe9
Moved simple_attributes and annotation_types lists into merge methods.
fherreazcue Nov 29, 2023
8938b7a
Improved merge all types of resources test
fherreazcue Nov 29, 2023
35536fa
Merge annotations_by
fherreazcue Nov 29, 2023
f19cc32
simplify merge annotations test
fherreazcue Nov 30, 2023
122eb02
Improved merge permissions test
fherreazcue Nov 30, 2023
84926ca
Use destroy!
fherreazcue Nov 30, 2023
a436c70
Merge branch 'main' into merge-accounts
stuzart Feb 5, 2024
6e2b09b
Merge branch 'main' into merge-accounts
stuzart Feb 7, 2024
e7b8efc
Merge branch 'main' into merge-accounts
stuzart Jul 16, 2024
4cbc593
Merge branch 'main' into merge-accounts
stuzart Jul 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use in_batches for update_all or destroy_all.
  • Loading branch information
fherreazcue committed Nov 29, 2023
commit ebb646326f3597696fd28a9e879a50520cbf23c4
14 changes: 7 additions & 7 deletions lib/seek/merging/person_merge.rb
Original file line number Diff line number Diff line change
@@ -63,12 +63,12 @@ def merge_annotations(other_person)
def merge_resources(other_person)
# Contributed
Person::RELATED_RESOURCE_TYPES.each do |resource_type|
other_person.send("contributed_#{resource_type.underscore.pluralize}").update_all(contributor_id: id)
other_person.send("contributed_#{resource_type.underscore.pluralize}").in_batches.update_all(contributor_id: id)
end
# Created
duplicated = other_person.created_items.pluck(:id) & created_items.pluck(:id)
AssetsCreator.where(creator_id: other_person.id, asset_id: duplicated).destroy_all
AssetsCreator.where(creator_id: other_person.id).update_all(creator_id: id)
AssetsCreator.where(creator_id: other_person.id, asset_id: duplicated).in_batches.destroy_all
AssetsCreator.where(creator_id: other_person.id).in_batches.update_all(creator_id: id)
end

def merge_associations(other_person, assoc, duplicates_match, update_hash)
@@ -78,9 +78,9 @@ def merge_associations(other_person, assoc, duplicates_match, update_hash)
duplicated = duplicated.map { |item| [item] } if duplicates_match.length == 1

duplicated_hash = Hash[duplicates_match.zip(duplicated.transpose)]
other_person.send(assoc).where(duplicated_hash).destroy_all
other_person.send(assoc).where(duplicated_hash).in_batches.destroy_all

other_person.send(assoc).update_all(update_hash)
other_person.send(assoc).in_batches.update_all(update_hash)
end

def merge_user(other_person)
@@ -103,9 +103,9 @@ def merge_user_associations(other_person, assoc, duplicates_match, update_hash)
duplicated = duplicated.map { |item| [item] } if duplicates_match.length == 1

duplicated_hash = Hash[duplicates_match.zip(duplicated.transpose)]
other_person.user.send(assoc).where(duplicated_hash).destroy_all
other_person.user.send(assoc).where(duplicated_hash).in_batches.destroy_all

other_person.user.send(assoc).update_all(update_hash)
other_person.user.send(assoc).in_batches.update_all(update_hash)
end

end