Skip to content

Commit

Permalink
matches: добавил список матчей в виде json-а для Робота
Browse files Browse the repository at this point in the history
  • Loading branch information
em92 committed Apr 6, 2024
1 parent 4819727 commit ce505b9
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions qllr/blueprints/matches/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from time import time

from asyncpg import Connection
from starlette.requests import Request
from starlette.responses import JSONResponse
Expand Down Expand Up @@ -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),
Expand All @@ -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),
]

0 comments on commit ce505b9

Please sign in to comment.