Skip to content

Commit af0376e

Browse files
authored
Merge pull request #540 from Bot-detector/develop
Release
2 parents 567de06 + b3e5daf commit af0376e

19 files changed

Lines changed: 1701 additions & 167 deletions

.pre-commit-config.yaml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
repos:
2-
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v2.3.0
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
# Ruff version.
4+
rev: v0.7.4
45
hooks:
5-
- id: check-yaml
6-
- repo: https://github.com/psf/black
7-
rev: 22.10.0
8-
hooks:
9-
- id: black
6+
# Run the linter.
7+
- id: ruff
8+
types_or: [python, pyi]
9+
args: [--fix]
10+
# Run the formatter.
11+
- id: ruff-format
12+
types_or: [python, pyi]

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.10-slim as base
1+
FROM python:3.10-slim AS base
22

33
ARG api_port
44
ENV UVICORN_PORT ${api_port}
@@ -23,9 +23,9 @@ RUN pip install --no-cache-dir -r requirements.txt
2323
COPY ./src /project/src
2424

2525
# production image
26-
FROM base as production
26+
FROM base AS production
2727
# Creates a non-root user with an explicit UID and adds permission to access the /project folder
2828
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /project
2929
USER appuser
3030

31-
CMD ["uvicorn", "src.core.server:app", "--proxy-headers", "--host", "0.0.0.0"]
31+
CMD ["uvicorn", "src.core.server:app", "--proxy-headers", "--host", "0.0.0.0", "--log-level", "warning"]

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ services:
3232
args:
3333
root_path: /
3434
api_port: 5000
35-
command: uvicorn src.core.server:app --host 0.0.0.0 --reload --reload-include src/*
35+
command: uvicorn src.core.server:app --host 0.0.0.0 --reload --reload-include src/* --log-level warning
3636
container_name: bd-dev-api
3737
environment:
3838
- sql_uri=mysql+asyncmy://root:root_bot_buster@mysql/playerdata

pyproject.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[project]
2+
name = "core-api"
3+
version = "0.1.0"
4+
description = "Add your description here"
5+
readme = "README.md"
6+
requires-python = ">=3.10"
7+
dependencies = [
8+
"aiohttp>=3.9.5",
9+
"asyncmy==0.2.8",
10+
"fastapi[standard]>=0.115.5",
11+
"pandas>=2.0.3",
12+
"prometheus-client>=0.21.0",
13+
"python-dotenv==1.0.0",
14+
"sqlalchemy==2.0.19",
15+
"starlette-prometheus>=0.9.0",
16+
]
17+
18+
[dependency-groups]
19+
dev = [
20+
"httpx>=0.28.0",
21+
"pytest-asyncio>=0.24.0",
22+
"pytest>=8.3.3",
23+
"ruff>=0.8.1",
24+
]

requirements.txt

1.01 KB
Binary file not shown.

requirements.txt.old

1.43 KB
Binary file not shown.

src/__init__.py

Whitespace-only changes.

src/api/legacy/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from fastapi import APIRouter
22

3-
from src.api.legacy import legacy, legacy_debug
3+
from src.api.legacy import legacy
44

55
router = APIRouter()
66

77
router.include_router(legacy.router)
8-
router.include_router(legacy_debug.router)
8+
# router.include_router(legacy_debug.router)

src/api/legacy/legacy.py

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -826,80 +826,6 @@ async def receive_plugin_feedback(feedback: Feedback, version: str = None):
826826

827827
return {"OK": "OK"}
828828

829-
830-
@router.get("/site/highscores/{token}/{ofInterest}", tags=["Legacy"])
831-
@router.get("/site/highscores/{token}/{ofInterest}/{row_count}/{page}", tags=["Legacy"])
832-
async def get_highscores(
833-
token: str,
834-
request: Request,
835-
ofInterest: int = None,
836-
row_count: Optional[int] = 100_000,
837-
page: Optional[int] = 1,
838-
):
839-
await verify_token(
840-
token,
841-
verification="request_highscores",
842-
route=logging_helpers.build_route_log_string(request, [token]),
843-
)
844-
845-
if ofInterest is None:
846-
sql = """
847-
SELECT
848-
hdl.*,
849-
pl.name
850-
FROM playerHiscoreDataLatest hdl
851-
inner join Players pl on(hdl.Player_id=pl.id)
852-
"""
853-
else:
854-
sql = """
855-
SELECT
856-
htl.*,
857-
poi.name
858-
FROM playerHiscoreDataLatest htl
859-
INNER JOIN playersOfInterest poi ON (htl.Player_id = poi.id)
860-
"""
861-
862-
data = await execute_sql(sql, row_count=row_count, page=page)
863-
return data.rows2dict() if data is not None else {}
864-
865-
866-
@router.get("site/players/{token}/{ofInterest}/{row_count}/{page}", tags=["Legacy"])
867-
async def get_players(
868-
token: str,
869-
request: Request,
870-
ofInterest: int = None,
871-
row_count: int = 100_000,
872-
page: int = 1,
873-
):
874-
await verify_token(
875-
token,
876-
verification="request_highscores",
877-
route=logging_helpers.build_route_log_string(request, [token]),
878-
)
879-
880-
# get data
881-
if ofInterest is None:
882-
sql = "select * from Players"
883-
else:
884-
sql = "select * from playersOfInterest"
885-
886-
data = await execute_sql(sql, row_count=row_count, page=page)
887-
return data.rows2dict() if data is not None else {}
888-
889-
890-
@router.get("/site/labels/{token}", tags=["Legacy"])
891-
async def get_labels(token, request: Request):
892-
await verify_token(
893-
token,
894-
verification="request_highscores",
895-
route=logging_helpers.build_route_log_string(request, [token]),
896-
)
897-
898-
sql = "select * from Labels"
899-
data = await execute_sql(sql)
900-
return data.rows2dict() if data is not None else {}
901-
902-
903829
@router.post("/site/verify/{token}", tags=["Legacy"])
904830
async def verify_bot(token: str, bots: bots, request: Request):
905831
await verify_token(

0 commit comments

Comments
 (0)