Fix Relationship Graph for extraneous families when using filter (#576)

Fixes #10492
This commit is contained in:
Paul Culley 2018-03-08 16:26:00 -06:00 committed by Sam Manzi
parent 8c1a244b1e
commit a668f0d04f

View File

@ -194,6 +194,8 @@ class RelGraphReport(Report):
person_handles = self._filter.apply(self._db,
self._db.iter_person_handles(),
user=self._user)
# Hash people in a dictionary for faster inclusion checking
self.persons = set(person_handles)
person_handles = self.sort_persons(person_handles)
@ -216,7 +218,7 @@ class RelGraphReport(Report):
person = self.database.get_person_from_handle(person_handle)
has_parent = False
for parent_handle in find_parents(self.database, person):
if parent_handle not in person_handle_list:
if parent_handle not in self.persons:
continue
has_parent = True
if not has_parent:
@ -233,7 +235,7 @@ class RelGraphReport(Report):
cur = todolist.pop(0)
if cur in p_done:
continue
if cur not in person_handle_list:
if cur not in self.persons:
p_done.add(cur)
continue
person = self.database.get_person_from_handle(cur)
@ -243,7 +245,7 @@ class RelGraphReport(Report):
for parent_handle in find_parents(self.database, person):
if not parent_handle or parent_handle in p_done:
continue
if parent_handle not in person_handle_list:
if parent_handle not in self.persons:
continue
todolist.insert(0, parent_handle)
missing_parents = True
@ -280,9 +282,6 @@ class RelGraphReport(Report):
returns string of Graphviz edges linking parents to families or
children
"""
# Hash people in a dictionary for faster inclusion checking
person_dict = dict([handle, 1] for handle in person_handles)
for person_handle in person_handles:
if self._user:
self._user.step_progress()
@ -297,19 +296,19 @@ class RelGraphReport(Report):
if child_ref.ref == person_handle:
frel = child_ref.frel
mrel = child_ref.mrel
elif child_ref.ref in person_dict:
elif child_ref.ref in self.persons:
sibling = True
if (self.show_families and
((father_handle and father_handle in person_dict) or
(mother_handle and mother_handle in person_dict) or
((father_handle and father_handle in self.persons) or
(mother_handle and mother_handle in self.persons) or
sibling)):
# Link to the family node if either parent is in graph
self.add_family_link(p_id, family, frel, mrel)
else:
# Link to the parents' nodes directly, if they are in graph
if father_handle and father_handle in person_dict:
if father_handle and father_handle in self.persons:
self.add_parent_link(p_id, father_handle, frel)
if mother_handle and mother_handle in person_dict:
if mother_handle and mother_handle in self.persons:
self.add_parent_link(p_id, mother_handle, mrel)
def add_family_link(self, p_id, family, frel, mrel):
@ -395,7 +394,8 @@ class RelGraphReport(Report):
if family is None:
continue
for child_ref in family.get_child_ref_list():
if child_ref.ref != person_handle:
if (child_ref.ref != person_handle and
child_ref.ref in self.persons):
families_done.add(fam_handle)
self.__add_family(fam_handle)