Commits

Juarez Bochi  committed 0366ca7

Prefetching correct property

  • Participants
  • Parent commits e271a1f

Comments (0)

Files changed (1)

 class EventHandler(MyRequestHandler):
     def get_by_event_type(self, iata_code, departure):
         airport = Airport.all().filter('iata_code =', iata_code).get()
+
         if departure:
             query = Departure.all().filter('source =', airport)
+            property = Departure.destination
         else:
             query = Arrival.all().filter('destination =', airport)
+            property = Departure.source
 
         events = query.filter('date =', date.today())\
                       .order('confirmed').fetch(1000)
 
         prefetch_refprop(events, Event.company)
-        prefetch_refprop(events, Event.source)
+        prefetch_refprop(events, property)
 
         template_values = {'airport': airport,
                            'events': events,