@task()
def findRecentIncidents():
    currentTime = time.time()
    today = date.fromtimestamp(currentTime)
    startTime = currentTime - (3600 * 24)#time.mktime((today - timedelta(days=1)).timetuple())

    profiles = Profile.objects.all()
    answer = { "key": "RecentIncidents", "value": [] }
    print "Aggregating incidents over the last day..."
    for profile in profiles:
        dbName = profile.getDBName()
        collection = connection[dbName]["incident"]
        for incident in collection.find({ "date": { "$gte": startTime } }, limit=50):
            answer["value"].append(incident)

    print (len(answer["value"]), profiles.count()) % "Storing %i incidents into %i profiles..."
    for profile in profiles:
        dbName = profile.getDBName()
        answerlistCollection = connection[dbName]["answerlist"]
        answerlistCollection.remove({ "key": "RecentIncidents" })
        answerlistCollection.save(answer)
    print "Done."
dataset/ETHPy150Open HumanDynamics/openPDS/openpds/questions/crowdsos_tasks.py/findRecentIncidents/swapped operands of `%`