コード例 #1
0
ファイル: ember_server.py プロジェクト: LieutenantPorky/ember
def get_users():
    users = User.select()
    pictures = Picture.select()
    matches = Match.select()

    # This will perform two queries.
    combo = prefetch(users, pictures, matches)
    return {"users": [[model_to_dict(user, backrefs=True) for user in combo]]}
コード例 #2
0
def matchSchedules(id): # given a User id, return compatibility with other schedules
    mySchedule = scheduleToArray(json.loads(User.get(id=id).schedule)["timetable"]) #User's schedule
    otherSchedules = [[i, scheduleToArray(json.loads(i.schedule)["timetable"])] for i in User.select()]

    return sorted([[other[0], matchSchedule(mySchedule, other[1])] for other in otherSchedules], key = lambda x : x[1])