feat: metadata
Docker Build / build (push) Has been cancelled
Python Lint CI / ruff (push) Has been cancelled
Python Lint CI / ruff-format-check (push) Has been cancelled
Python Lint CI / ty (push) Has been cancelled
TS Lint / ESLint (push) Has been cancelled
TS Lint / Oxlint (push) Has been cancelled
TS Lint / TypeScript (push) Has been cancelled
Docker Build / build (push) Has been cancelled
Python Lint CI / ruff (push) Has been cancelled
Python Lint CI / ruff-format-check (push) Has been cancelled
Python Lint CI / ty (push) Has been cancelled
TS Lint / ESLint (push) Has been cancelled
TS Lint / Oxlint (push) Has been cancelled
TS Lint / TypeScript (push) Has been cancelled
This commit is contained in:
@@ -6,6 +6,7 @@ import flask_limiter
|
||||
import flask_limiter.util
|
||||
import gunicorn.app.base
|
||||
import tortoise
|
||||
from tortoise.functions import Count
|
||||
|
||||
from app import PKG_NAME
|
||||
from app.lang import get_lang
|
||||
@@ -56,6 +57,18 @@ class Server(gunicorn.app.base.BaseApplication):
|
||||
lang=lambda key: get_lang(locale, key),
|
||||
)
|
||||
|
||||
@self.app.route("/api/meta", methods=["GET"])
|
||||
async def metadata() -> dict:
|
||||
return {
|
||||
"tasks": await Task.all().count(),
|
||||
"lists": (
|
||||
await Task.all()
|
||||
.annotate(count=Count("list_name", distinct=True))
|
||||
.first()
|
||||
.values("count")
|
||||
)["count"],
|
||||
}
|
||||
|
||||
@self.app.route("/api/lists/<list_name>/tasks", methods=["GET"])
|
||||
async def get_tasks(list_name: str) -> list:
|
||||
return await Task.filter(list_name=list_name[:128]).values()
|
||||
|
||||
Reference in New Issue
Block a user