示例#1
0
 def games_on_day(session, timestamp):
     day_start = dateutils.midnight_before(timestamp)
     day_end = dateutils.midnight_after(timestamp)
     results = (session.query(Game).filter(
         Game.timestamp >= day_start).filter(
             Game.timestamp < day_end).filter(Game.nplayers >= 2).order_by(
                 Game.timestamp))
     return results
示例#2
0
 def games_on_day(session, timestamp):
     day_start = dateutils.midnight_before(timestamp)
     day_end = dateutils.midnight_after(timestamp)
     results = (session.query(Game)
                       .filter(Game.timestamp >= day_start)
                       .filter(Game.timestamp < day_end)
                       .filter(Game.nplayers >= 2)
                       .order_by(Game.timestamp))
     return results
示例#3
0
 def played_games(self, session, day=None, limit=1000):
     played = (session.query(GamePlayer).join(GamePlayer.game).filter(
         GamePlayer.player == self).filter(Game.nplayers >= 2).order_by(
             desc(Game.timestamp)))
     if day is not None:
         day_start = dateutils.midnight_before(day)
         day_end = dateutils.midnight_after(day)
         played = (played.filter(Game.timestamp >= day_start).filter(
             Game.timestamp < day_end))
     played = played.limit(limit)
     return [item.game for item in played]
示例#4
0
 def played_games(self, session, day=None, limit=1000):
     played = (session.query(GamePlayer)
                      .join(GamePlayer.game)
                      .filter(GamePlayer.player == self)
                      .filter(Game.nplayers >= 2)
                      .order_by(desc(Game.timestamp)))
     if day is not None:
         day_start = dateutils.midnight_before(day)
         day_end = dateutils.midnight_after(day)
         played = (played.filter(Game.timestamp >= day_start)
                         .filter(Game.timestamp < day_end))
     played = played.limit(limit)
     return [item.game for item in played]