fix missing game_files generation

This commit is contained in:
NoeBerdoz
2025-04-13 03:38:42 +02:00
parent f399b6dac4
commit 06c516b615
2 changed files with 11 additions and 2 deletions

5
app.py
View File

@ -8,6 +8,7 @@ from dto.requests import GameStartRequestDTO, GameDecisionRequestDTO
from dto.responses import GameStartResponseWithBotDecisionDTO, GameDecisionResponseWithBotDecisionDTO from dto.responses import GameStartResponseWithBotDecisionDTO, GameDecisionResponseWithBotDecisionDTO
from services.julius_baer_api_client import JuliusBaerApiClient from services.julius_baer_api_client import JuliusBaerApiClient
from services.advisor import Advisor from services.advisor import Advisor
from utils.storage.game_files_manager import store_game_round_data
app = Flask(__name__) app = Flask(__name__)
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - [%(module)s] - %(message)s') logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - [%(module)s] - %(message)s')
@ -32,6 +33,8 @@ def new_game():
bot_reason=bot_decision.reason, bot_reason=bot_decision.reason,
) )
store_game_round_data(bot_decision.answer, res_with_bot_decision, res.score, str(res.session_id), 'active')
return res_with_bot_decision.model_dump_json() return res_with_bot_decision.model_dump_json()
@ -57,6 +60,8 @@ def next_client():
bot_reason=bot_decision.reason, bot_reason=bot_decision.reason,
) )
store_game_round_data(bot_decision.answer, res_with_bot_decision, res.score, str(session_id), res.status)
return res_with_bot_decision.model_dump_json() return res_with_bot_decision.model_dump_json()

View File

@ -6,13 +6,17 @@ import json
from typing import Dict, Any from typing import Dict, Any
from pathlib import Path from pathlib import Path
from dto.responses import GameStartResponseDTO, GameDecisionResponseDTO from dto.responses import GameStartResponseWithBotDecisionDTO, GameDecisionResponseWithBotDecisionDTO
GAME_FILES_DIR = config.GAME_FILES_DIR GAME_FILES_DIR = config.GAME_FILES_DIR
# Define padding for round numbers (e.g., 6 digits for up to 999,999 rounds) # Define padding for round numbers (e.g., 6 digits for up to 999,999 rounds)
FOLDER_ROUND_PADDING = 6 FOLDER_ROUND_PADDING = 6
############################
# WARNING - Technical Debt #
############################
def _get_previous_round_folder(current_round: int, session_id: str) -> str | None: def _get_previous_round_folder(current_round: int, session_id: str) -> str | None:
""" """
@ -83,7 +87,7 @@ def store_decoded_files(response: Dict[str, Any] | None, directory: str):
logging.error(f"[!] Unexpected error saving file '{key}{extension}' in {directory}: {e}") logging.error(f"[!] Unexpected error saving file '{key}{extension}' in {directory}: {e}")
def store_game_round_data(decision: str, response: GameStartResponseDTO | GameDecisionResponseDTO, round_number: int, def store_game_round_data(decision: str, response: GameStartResponseWithBotDecisionDTO | GameDecisionResponseWithBotDecisionDTO, round_number: int,
session_id: str, status: str): session_id: str, status: str):
""" """
Logs structured response data and saves associated client files. Logs structured response data and saves associated client files.