9127 : Geography : performance issue when selecting the events or places views.

This commit is contained in:
SNoiraud 2015-12-23 11:10:27 +01:00
parent ab67c786b0
commit 0ff9363d72
2 changed files with 23 additions and 17 deletions

View File

@ -133,6 +133,7 @@ class GeoEvents(GeoGraphyView):
self.generic_filter = None self.generic_filter = None
self.additional_uis.append(self.additional_ui()) self.additional_uis.append(self.additional_ui())
self.no_show_places_in_status_bar = False self.no_show_places_in_status_bar = False
self.show_all = False
def get_title(self): def get_title(self):
""" """
@ -178,6 +179,7 @@ class GeoEvents(GeoGraphyView):
""" """
Ask to show all events. Ask to show all events.
""" """
self.show_all = True
self._createmap(None) self._createmap(None)
def build_tree(self): def build_tree(self):
@ -283,20 +285,20 @@ class GeoEvents(GeoGraphyView):
self.cal = config.get('preferences.calendar-format-report') self.cal = config.get('preferences.calendar-format-report')
self.no_show_places_in_status_bar = False self.no_show_places_in_status_bar = False
if self.generic_filter: if self.show_all:
self.show_all = False
events_handle = dbstate.db.get_event_handles()
for event_hdl in events_handle:
event = dbstate.db.get_event_from_handle(event_hdl)
self._createmap_for_one_event(event)
elif self.generic_filter:
events_list = self.generic_filter.apply(dbstate.db) events_list = self.generic_filter.apply(dbstate.db)
for event_handle in events_list: for event_handle in events_list:
event = dbstate.db.get_event_from_handle(event_handle) event = dbstate.db.get_event_from_handle(event_handle)
self._createmap_for_one_event(event) self._createmap_for_one_event(event)
else: elif obj:
if obj is None: event = dbstate.db.get_event_from_handle(obj)
events_handle = dbstate.db.get_event_handles() self._createmap_for_one_event(event)
for event_hdl in events_handle:
event = dbstate.db.get_event_from_handle(event_hdl)
self._createmap_for_one_event(event)
else:
event = dbstate.db.get_event_from_handle(obj)
self._createmap_for_one_event(event)
self.sort = sorted(self.place_list, self.sort = sorted(self.place_list,
key=operator.itemgetter(3, 4, 6) key=operator.itemgetter(3, 4, 6)
) )

View File

@ -133,6 +133,7 @@ class GeoPlaces(GeoGraphyView):
self.generic_filter = None self.generic_filter = None
self.additional_uis.append(self.additional_ui()) self.additional_uis.append(self.additional_ui())
self.no_show_places_in_status_bar = False self.no_show_places_in_status_bar = False
self.show_all = False
def get_title(self): def get_title(self):
""" """
@ -178,6 +179,7 @@ class GeoPlaces(GeoGraphyView):
""" """
Ask to show all places. Ask to show all places.
""" """
self.show_all = True
self._createmap(None) self._createmap(None)
def build_tree(self): def build_tree(self):
@ -256,12 +258,8 @@ class GeoPlaces(GeoGraphyView):
# 65598 places : createmap : 08'48"; create_markers : 0'01"; draw markers : 0'07" # 65598 places : createmap : 08'48"; create_markers : 0'01"; draw markers : 0'07"
_LOG.debug("%s" % time.strftime("start createmap : " _LOG.debug("%s" % time.strftime("start createmap : "
"%a %d %b %Y %H:%M:%S", time.gmtime())) "%a %d %b %Y %H:%M:%S", time.gmtime()))
if self.generic_filter: if self.show_all:
place_list = self.generic_filter.apply(dbstate.db) self.show_all = False
for place_handle in place_list:
place = dbstate.db.get_place_from_handle(place_handle)
self._create_one_place(place)
else:
try: try:
places_handle = dbstate.db.get_place_handles() places_handle = dbstate.db.get_place_handles()
except: except:
@ -269,8 +267,14 @@ class GeoPlaces(GeoGraphyView):
for place_hdl in places_handle: for place_hdl in places_handle:
place = dbstate.db.get_place_from_handle(place_hdl) place = dbstate.db.get_place_from_handle(place_hdl)
self._create_one_place(place) self._create_one_place(place)
if place_x: elif self.generic_filter:
place_list = self.generic_filter.apply(dbstate.db)
for place_handle in place_list:
place = dbstate.db.get_place_from_handle(place_handle)
self._create_one_place(place)
elif place_x:
place = dbstate.db.get_place_from_handle(place_x) place = dbstate.db.get_place_from_handle(place_x)
self._create_one_place(place)
if ( place.get_latitude() != "" and place.get_longitude() != "" ): if ( place.get_latitude() != "" and place.get_longitude() != "" ):
self.osm.set_center_and_zoom(float(place.get_latitude()), self.osm.set_center_and_zoom(float(place.get_latitude()),
float(place.get_longitude()), float(place.get_longitude()),