Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aggregate score stats APIs #126

Merged
merged 9 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/production-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ jobs:

- name: Get kubeconfig from github secrets
run: |
mkdir -p $HOME/.kube
echo "${{ secrets.KUBECONFIG }}" > $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
chmod 600 $HOME/.kube/config
mkdir -p $HOME/.kube
echo "${{ secrets.KUBECONFIG }}" > $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
chmod 600 $HOME/.kube/config

- name: Install helm
uses: azure/setup-helm@v3
Expand Down
6 changes: 6 additions & 0 deletions app/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from fastapi.responses import RedirectResponse

import app.state.services
from . import aggregate_score_stats
from . import direct
from . import favourites
from . import lastfm
Expand Down Expand Up @@ -71,6 +72,11 @@ async def healthcheck() -> Response:

router.add_api_route("/api/v1/pp", pp.calculate_pp)

router.add_api_route(
"/public/api/v1/aggregate-score-stats/total-scores-set",
aggregate_score_stats.total_scores_set,
)


@router.get("/web/bancho-connect.php")
async def bancho_connect() -> Response:
Expand Down
7 changes: 7 additions & 0 deletions app/api/aggregate_score_stats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from __future__ import annotations

import app.usecases


async def total_scores_set() -> int:
return await app.usecases.aggregate_score_stats.total_scores_set()
1 change: 1 addition & 0 deletions app/usecases/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

from . import aggregate_score_stats
from . import akatsuki_beatmaps
from . import chat
from . import countries
Expand Down
20 changes: 20 additions & 0 deletions app/usecases/aggregate_score_stats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from __future__ import annotations

import app.state.services


async def total_scores_set() -> int:
return sum(
[
(
await app.state.services.database.fetch_val(
f"""\
SELECT count(*)
FROM {table}
""",
)
or 0
)
for table in ("scores", "scores_relax", "scores_ap")
],
)