From 7577e3afee7618c6ce9fc1c98fdaf68c5bca376b Mon Sep 17 00:00:00 2001 From: c0de Date: Fri, 9 Dec 2022 21:34:32 -0600 Subject: [PATCH] generate the uuid on the model --- database/models.py | 5 +++-- game/new_game.py | 4 +--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/database/models.py b/database/models.py index 57e7447..e3dd96a 100644 --- a/database/models.py +++ b/database/models.py @@ -9,6 +9,7 @@ """ import os +import uuid import datetime from peewee import ( @@ -55,7 +56,7 @@ class PlayerModel(BaseModel): class GameModel(BaseModel): """Games that are ran""" - game_id = UUIDField(primary_key=True) + game_id = UUIDField(primary_key=True, default=uuid.uuid4) server_id = IntegerField() pitch_value = IntegerField(null=True) @@ -66,7 +67,7 @@ class GameModel(BaseModel): class GuessModel(BaseModel): """Guesses for a particular game""" - guess_id = UUIDField(primary_key=True) + guess_id = UUIDField(primary_key=True, default=uuid.uuid4) player = ForeignKeyField(PlayerModel, backref="guesses") game = ForeignKeyField(GameModel, backref="guesses") diff --git a/game/new_game.py b/game/new_game.py index 9b1108b..337de85 100644 --- a/game/new_game.py +++ b/game/new_game.py @@ -4,8 +4,6 @@ # pylint: disable=missing-module-docstring -import uuid - from database.models import GameModel as Game from game.base import BaseGameManager @@ -28,6 +26,6 @@ class NewGameManager(BaseGameManager): self.is_running = True # game.pitch_value is unknown at the start of the game - self.game = Game.create(game_id=uuid.uuid4(), server_id=self.message.channel.id) + self.game = Game.create(server_id=self.message.channel.id) await self.message.channel.send("Send me your guesses with !guess ")