diff --git a/app/models/game.py b/app/models/game.py index 6189739..67d5444 100644 --- a/app/models/game.py +++ b/app/models/game.py @@ -29,7 +29,7 @@ class Game(db.Model): backref=db.backref('game', lazy='joined'), cascade="save-update, merge, delete, delete-orphan") - def last_player_locations(self, offset): + def last_player_locations(self, offset=None): # pylint: disable=not-an-iterable return [player.last_location(offset=offset) for player in self.players if player.user.locations] diff --git a/app/models/user.py b/app/models/user.py index 468cb31..127012a 100644 --- a/app/models/user.py +++ b/app/models/user.py @@ -42,7 +42,7 @@ class User(UserMixin, db.Model): return False return check_password_hash(self.password_hash, password) - def locations_during_game(self, game, offset=0): + def locations_during_game(self, game, offset=None): ''' Returns users locations during game. @@ -51,6 +51,8 @@ class User(UserMixin, db.Model): offset (int): Offset in minutes. Only locations older than this amount of minutes will be returned. ''' # pylint: disable=not-an-iterable + if offset is None: + offset = 0 if not self.locations: return None if game is None: @@ -67,7 +69,7 @@ class User(UserMixin, db.Model): if location.timestamp > game_start and location.timestamp < game_end and datetime.utcnow() - location.timestamp > timedelta(minutes=offset)] - def last_location(self, game=None, offset=0): + def last_location(self, game=None, offset=None): ''' Returns users last recorded location. @@ -76,6 +78,8 @@ class User(UserMixin, db.Model): offset (int): Offset in minutes. Only locations older than this amount of minutes will be returned. ''' # pylint: disable=[not-an-iterable, unsubscriptable-object] + if offset is None: + offset = 0 if not self.locations: return None if game is None: