diff --git a/qllr/blueprints/matches/__init__.py b/qllr/blueprints/matches/__init__.py index 50c3309..68682cd 100644 --- a/qllr/blueprints/matches/__init__.py +++ b/qllr/blueprints/matches/__init__.py @@ -1,3 +1,5 @@ +from time import time + from asyncpg import Connection from starlette.requests import Request from starlette.responses import JSONResponse @@ -35,6 +37,17 @@ async def get_document(self, request: Request, con: Connection): return templates.TemplateResponse("match_list.html", context) +class Last24HoursMatchesForRobot(Endpoint): + async def get_document(self, request: Request, con: Connection): + gametype = request.path_params["gametype"] + + context = await get_last_matches( + con, gametype, None, 0, int(time() - 60 * 60 * 24), int(time()) + ) + context["gametype"] = gametype + return JSONResponse(context) + + routes = [ Route("/", endpoint=MatchesHtml), Route("/{page:int}/", endpoint=MatchesHtml), @@ -44,5 +57,6 @@ async def get_document(self, request: Request, con: Connection): Route("/player/{steam_id:int}/{gametype}/{page:int}/", endpoint=MatchesHtml), Route("/player/{steam_id:int}/{gametype}/top", endpoint=BestMatchesHtml), Route("/{gametype}/", endpoint=MatchesHtml), + Route("/{gametype}/robot24hour.json", endpoint=Last24HoursMatchesForRobot), Route("/{gametype}/{page:int}/", endpoint=MatchesHtml), ]