Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test endpoint to list all sessions.
Browse files Browse the repository at this point in the history
sei-jvessella committed Feb 5, 2024
1 parent 364bed1 commit 6fe01c4
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions gamebrain/db.py
Original file line number Diff line number Diff line change
@@ -301,6 +301,10 @@ async def get_active_game_sessions() -> list[dict]:
)


async def get_all_sessions() -> list[dict]:
return await DBManager.get_rows(DBManager.GameSession)


async def get_active_teams() -> list[dict]:
return await DBManager.get_rows(
DBManager.TeamData,
11 changes: 8 additions & 3 deletions gamebrain/test_endpoints.py
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@
from .auth import admin_api_key_dependency
from .config import get_settings, SettingsModel
from .clients import topomojo
from .db import get_active_game_sessions
from .db import get_active_game_sessions, get_all_sessions
from .gamedata.cache import (
GameDataCacheSnapshot,
GameStateManager,
@@ -251,11 +251,16 @@ async def _reload_state_from_file(file: TextIO | BinaryIO):
await GameStateManager.init(new_state, GameStateManager._settings)


@test_router.get("/sessions")
async def list_sessions():
@test_router.get("/sessions/active")
async def list_active_sessions():
return await get_active_game_sessions()


@test_router.get("/sessions/all")
async def list_all_sessions():
return await get_all_sessions()


@test_router.get("/end_team_game/{team_id}")
async def end_team_game(team_id: str):
await cleanup_team(team_id)

0 comments on commit 6fe01c4

Please sign in to comment.