|
13 | 13 | from fastapi.security import APIKeyHeader |
14 | 14 | from plugins.creditsystem.squadron import Squadron |
15 | 15 | from plugins.userstats.filter import StatisticsFilter, PeriodFilter |
| 16 | +from psycopg.errors import UndefinedTable |
16 | 17 | from psycopg.rows import dict_row |
17 | 18 | from services.bot import DCSServerBot |
18 | 19 | from services.servicebus import ServiceBus |
@@ -1947,18 +1948,21 @@ async def traps(self, nick: str = Form(None), date: str | None = Form(None), |
1947 | 1948 | else: |
1948 | 1949 | join = "" |
1949 | 1950 | where = "WHERE t.player_ucid = %(ucid)s" |
1950 | | - async with self.apool.connection() as conn: |
1951 | | - async with conn.cursor(row_factory=dict_row) as cursor: |
1952 | | - ucid = await self.get_ucid(nick, date) |
1953 | | - await cursor.execute(f""" |
1954 | | - SELECT t.id, t.unit_type, t.grade, t.comment, t.place, t.trapcase, t.wire, t.night, t.points, t.time |
1955 | | - FROM traps t |
1956 | | - {join} |
1957 | | - {where} |
1958 | | - ORDER BY time DESC |
1959 | | - LIMIT {limit} OFFSET {offset} |
1960 | | - """, {"ucid": ucid, "server_name": resolved_server_name}) |
1961 | | - return [TrapEntry.model_validate(result) for result in await cursor.fetchall()] |
| 1951 | + try: |
| 1952 | + async with self.apool.connection() as conn: |
| 1953 | + async with conn.cursor(row_factory=dict_row) as cursor: |
| 1954 | + ucid = await self.get_ucid(nick, date) |
| 1955 | + await cursor.execute(f""" |
| 1956 | + SELECT t.id, t.unit_type, t.grade, t.comment, t.place, t.trapcase, t.wire, t.night, t.points, t.time |
| 1957 | + FROM traps t |
| 1958 | + {join} |
| 1959 | + {where} |
| 1960 | + ORDER BY time DESC |
| 1961 | + LIMIT {limit} OFFSET {offset} |
| 1962 | + """, {"ucid": ucid, "server_name": resolved_server_name}) |
| 1963 | + return [TrapEntry.model_validate(result) for result in await cursor.fetchall()] |
| 1964 | + except UndefinedTable: |
| 1965 | + raise HTTPException(status_code=500, detail="Greenieboard is not active on this server") |
1962 | 1966 |
|
1963 | 1967 | async def traps_image(self, trap_id: int = Query(...)): |
1964 | 1968 | self.log.debug(f'Calling /traps_image with trap_id="{trap_id}"') |
|
0 commit comments