Skip to content

Commit

Permalink
fixup! fixup! PersonSplitter view and class
Browse files Browse the repository at this point in the history
  • Loading branch information
VirginiaDooley committed May 28, 2024
1 parent 944f9c1 commit 7932e82
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ynr/apps/people/splitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class PersonSplitter:
def __init__(self, person):
self.person = person

def merged_from(self, person):
def merged_version(self, person):
"""Search through the person versions for the person merge history.
and return the last merge version.
"""
Expand All @@ -27,7 +27,7 @@ def merged_from(self, person):
# Divide all the version with the same ID into separate ordered
# lists, and record the parent of each version that we get from
# doing that:
merged_from = None
merged_versions = []
for version in ordered_versions:
version_id = version["version_id"]
person_id = version["data"]["id"]
Expand All @@ -47,17 +47,19 @@ def merged_from(self, person):
# and (b) the number of unique person IDs in the versions is one
# more than the number of versions that look like merges. We raise
# an exception in either of these situations.

number_of_person_ids = len(person_id_to_ordered_versions.keys())
number_of_merges = 0
for version in ordered_versions:
version_id = version["version_id"]
merged_from = is_a_merge(version)
if merged_from:
number_of_merges += 1
version_id_to_parent_ids[version_id] = merged_from
# TO DO: Do we want the most recent merged version or should we present the user with options?
merged_versions.append(version)
if number_of_person_ids != number_of_merges + 1:
raise ValueError(
"The number of unique person IDs in the versions is not one more than the number of versions that look like merges."
)

return merged_from
return merged_versions[0]["data"]

0 comments on commit 7932e82

Please sign in to comment.