Can you do filtering in memory?
This query would give you all of the journeys for a list of cars within the
date range:
carlist = ['123','333','543','753','963','1236']
start_date = datetime.datetime(2011, 1, 30)
end_date = datetime(2011, 2, 10)
journeys = Journey.all().filter('start >', start_date).filter('start <',
end_date).filter('car IN', carlist).order('-start').fetch(100)
len(journeys)
43 # <- since it's less than 100 I know I've gotten them all
then since the list is sorted I know the first entry per car is the most
recent journey:
results = {}
for journey in journeys:
... if journey.car in results:
... continue
... results[journey.car] = journey
len(results)
6
for result in results.values():
... print("%s : %s" % (result.car, result.start))
753 : 2011-02-09 12:38:48.887976
1236 : 2011-02-06 13:59:35.221003
963 : 2011-02-08 14:03:54.587609
333 : 2011-02-09 10:40:09.466700
543 : 2011-02-09 15:28:53.197123
123 : 2011-02-09 14:09:02.680870
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.