Add progress indication for filters with long 'prepare' times

And fix DeepRelationshipPathBetween for more accurate progress
And fix IsSiblingOfFilterMatch for HandleError
This commit is contained in:
prculley 2017-02-03 18:00:18 -06:00
parent 28bf8479fd
commit 79888ec6ea
8 changed files with 63 additions and 6 deletions

View File

@ -106,6 +106,8 @@ def find_deep_relations(db, user, person, path, seen, target_people):
if handle in seen:
return []
seen.append(handle)
if user:
user.step_progress()
return_paths = []
person_path = path + [handle]
@ -118,8 +120,6 @@ def find_deep_relations(db, user, person, path, seen, target_people):
for family_person in family_people:
pers = db.get_person_from_handle(family_person)
return_paths += find_deep_relations(db, user, pers, person_path, seen, target_people)
if user:
user.step_progress()
return return_paths

View File

@ -64,12 +64,20 @@ class HasCommonAncestorWithFilterMatch(HasCommonAncestorWith):
self.with_people = []
filt = MatchesFilter(self.list)
filt.requestprepare(db, user)
if user:
user.begin_progress(self.category,
_('Retrieving all sub-filter matches'),
db.get_number_of_people())
for handle in db.iter_person_handles():
person = db.get_person_from_handle(handle)
if user:
user.step_progress()
if person and filt.apply(db, person):
#store all people in the filter so as to compare later
self.with_people.append(person.handle)
#fill list of ancestor of person if not present yet
if handle not in self.ancestor_cache:
self.add_ancs(db, person)
if user:
user.end_progress()
filt.requestreset()

View File

@ -62,9 +62,17 @@ class IsAncestorOfFilterMatch(IsAncestorOf):
filt = MatchesFilter(self.list[0:1])
filt.requestprepare(db, user)
if user:
user.begin_progress(self.category,
_('Retrieving all sub-filter matches'),
db.get_number_of_people())
for person in db.iter_people():
if user:
user.step_progress()
if filt.apply(db, person):
self.init_ancestor_list(db, person, first)
if user:
user.end_progress()
filt.requestreset()
def reset(self):

View File

@ -53,9 +53,17 @@ class IsChildOfFilterMatch(Rule):
self.map = set()
filt = MatchesFilter(self.list)
filt.requestprepare(db, user)
if user:
user.begin_progress(self.category,
_('Retrieving all sub-filter matches'),
db.get_number_of_people())
for person in db.iter_people():
if user:
user.step_progress()
if filt.apply(db, person):
self.init_list(person)
if user:
user.end_progress()
filt.requestreset()
def reset(self):

View File

@ -55,8 +55,16 @@ class IsDescendantFamilyOfFilterMatch(IsDescendantFamilyOf):
filt = MatchesFilter(self.list[0:1])
filt.requestprepare(db, user)
if user:
user.begin_progress(self.category,
_('Retrieving all sub-filter matches'),
db.get_number_of_people())
for person in db.iter_people():
if user:
user.step_progress()
if filt.apply(db, person):
self.add_matches(person)
if user:
user.end_progress()
filt.requestreset()

View File

@ -62,9 +62,17 @@ class IsDescendantOfFilterMatch(IsDescendantOf):
filt = MatchesFilter(self.list[0:1])
filt.requestprepare(db, user)
if user:
user.begin_progress(self.category,
_('Retrieving all sub-filter matches'),
db.get_number_of_people())
for person in db.iter_people():
if user:
user.step_progress()
if filt.apply(db, person):
self.init_list(person, first)
if user:
user.end_progress()
filt.requestreset()
def reset(self):

View File

@ -53,9 +53,17 @@ class IsParentOfFilterMatch(Rule):
self.map = set()
filt = MatchesFilter(self.list)
filt.requestprepare(db, user)
if user:
user.begin_progress(self.category,
_('Retrieving all sub-filter matches'),
db.get_number_of_people())
for person in db.iter_people():
if user:
user.step_progress()
if filt.apply(db, person):
self.init_list(person)
if user:
user.end_progress()
filt.requestreset()
def reset(self):

View File

@ -52,9 +52,17 @@ class IsSiblingOfFilterMatch(Rule):
self.map = set()
filt = MatchesFilter(self.list)
filt.requestprepare(db, user)
if user:
user.begin_progress(self.category,
_('Retrieving all sub-filter matches'),
db.get_number_of_people())
for person in db.iter_people():
if user:
user.step_progress()
if filt.apply (db, person):
self.init_list (person)
if user:
user.end_progress()
filt.requestreset()
def reset(self):
@ -67,8 +75,9 @@ class IsSiblingOfFilterMatch(Rule):
if not person:
return
fam_id = person.get_main_parents_family_handle()
fam = self.db.get_family_from_handle(fam_id)
if fam:
self.map.update(child_ref.ref
for child_ref in fam.get_child_ref_list()
if fam_id:
fam = self.db.get_family_from_handle(fam_id)
if fam:
self.map.update(
child_ref.ref for child_ref in fam.get_child_ref_list()
if child_ref and child_ref.ref != person.handle)