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
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
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]
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]