Enable Team Tournaments, add Tournament Trees, implement temporary tree persistance #66

Merged
Typhus merged 7 commits from feature/enable-starting-tournaments-and-displaying-tournament-tree into main 2026-04-18 14:42:28 +00:00
2 changed files with 18 additions and 3 deletions
Showing only changes of commit a576b13fda - Show all commits

View File

@ -11,7 +11,7 @@ from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBo
from src.ezgg_lan_manager.types.DateUtil import weekday_to_display_text from src.ezgg_lan_manager.types.DateUtil import weekday_to_display_text
from src.ezgg_lan_manager.types.Participant import Participant from src.ezgg_lan_manager.types.Participant import Participant
from src.ezgg_lan_manager.types.Tournament import Tournament from src.ezgg_lan_manager.types.Tournament import Tournament
from src.ezgg_lan_manager.types.TournamentBase import TournamentStatus from src.ezgg_lan_manager.types.TournamentBase import TournamentStatus, TournamentError
logger = logging.getLogger(__name__.split(".")[-1]) logger = logging.getLogger(__name__.split(".")[-1])
@ -29,7 +29,10 @@ class ManageTournamentsPage(Component):
async def on_start_pressed(self, tournament_id: int) -> None: async def on_start_pressed(self, tournament_id: int) -> None:
logger.info(f"Starting tournament with ID {tournament_id}") logger.info(f"Starting tournament with ID {tournament_id}")
await self.session[TournamentService].start_tournament(tournament_id) try:
await self.session[TournamentService].start_tournament(tournament_id)
except TournamentError as e:
logger.error(f"Error trying to start tournament: {e}")
async def on_cancel_pressed(self, tournament_id: int) -> None: async def on_cancel_pressed(self, tournament_id: int) -> None:
logger.info(f"Canceling tournament with ID {tournament_id}") logger.info(f"Canceling tournament with ID {tournament_id}")
@ -92,9 +95,17 @@ class ManageTournamentsPage(Component):
font_size=1.2 font_size=1.2
), ),
margin_top=2, margin_top=2,
margin_bottom=2, margin_bottom=1,
align_x=0.5 align_x=0.5
), ),
Button(
content="Cache erneuern",
shape="rectangle",
style="colored-text",
margin_bottom=2,
align_x=0.5,
on_press=self.session[TournamentService].queue_cache_renewal
),
*tournament_rows *tournament_rows
) )
), ),

View File

@ -21,6 +21,10 @@ class TournamentService:
# Crude cache mechanism. If performance suffers, maybe implement a queue with Single-Owner-Pattern or a Lock # Crude cache mechanism. If performance suffers, maybe implement a queue with Single-Owner-Pattern or a Lock
self._cache: dict[int, Tournament] = {} self._cache: dict[int, Tournament] = {}
self._cache_dirty: bool = True # Setting this flag invokes cache update on next read self._cache_dirty: bool = True # Setting this flag invokes cache update on next read
async def queue_cache_renewal(self) -> None:
# Used in admin UI to provoke cache renewal after direct database access
self._cache_dirty = True
async def _update_cache(self) -> None: async def _update_cache(self) -> None:
tournaments = await self._db_service.get_all_tournaments() tournaments = await self._db_service.get_all_tournaments()