8466: [Performance] Handling many Events on a person

This commit is contained in:
Doug Blank 2016-05-22 12:42:32 -04:00 committed by prculley
parent 7ffb2403a2
commit 7f6803f9f6

View File

@ -118,7 +118,7 @@ class Events(Gramplet, DbGUIElement):
month, days" month, days"
""" """
date = event.get_date_object() date = event.get_date_object()
start_date = self.get_start_date() start_date = self.cached_start_date
if date and start_date: if date and start_date:
return (date - start_date).format(precision=age_precision) return (date - start_date).format(precision=age_precision)
else: else:
@ -129,7 +129,7 @@ class Events(Gramplet, DbGUIElement):
Returns a string version of number of days of age. Returns a string version of number of days of age.
""" """
date = event.get_date_object() date = event.get_date_object()
start_date = self.get_start_date() start_date = self.cached_start_date
if date and start_date: if date and start_date:
return "%09d" % int(date - start_date) return "%09d" % int(date - start_date)
else: else:
@ -171,6 +171,7 @@ class PersonEvents(Events):
Return True if the gramplet has data, else return False. Return True if the gramplet has data, else return False.
""" """
if active_person: if active_person:
self.cached_start_date = self.get_start_date()
if active_person.get_event_ref_list(): if active_person.get_event_ref_list():
return True return True
for family_handle in active_person.get_family_handle_list(): for family_handle in active_person.get_family_handle_list():
@ -178,6 +179,8 @@ class PersonEvents(Events):
if family: if family:
for event_ref in family.get_event_ref_list(): for event_ref in family.get_event_ref_list():
return True return True
else:
self.cached_start_date = None
return False return False
def main(self): # return false finishes def main(self): # return false finishes