Enable Team Tournaments, add Tournament Trees, implement temporary tree persistance #66
@ -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
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|||||||
@ -22,6 +22,10 @@ class TournamentService:
|
|||||||
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()
|
||||||
for tournament in tournaments:
|
for tournament in tournaments:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user