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()
|
||||
|
||||
@@ -84,5 +84,6 @@
|
||||
"save_button": "Save task",
|
||||
"clone_button": "Clone task",
|
||||
"delete_button": "Delete task",
|
||||
"recent": "Recent lists"
|
||||
"recent": "Recent lists",
|
||||
"metadata": "{lists} lists / {tasks} tasks"
|
||||
}
|
||||
|
||||
@@ -84,5 +84,6 @@
|
||||
"save_button": "Sauvegarder la tâche",
|
||||
"clone_button": "Cloner la tâche",
|
||||
"delete_button": "Supprimer la tâche",
|
||||
"recent": "Listes récentes"
|
||||
"recent": "Listes récentes",
|
||||
"metadata": "{lists} listes / {tasks} tâches"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import type { Metadata } from "@/types";
|
||||
|
||||
export async function getMetadata(): Promise<Metadata> {
|
||||
const response = await fetch(`/api/meta`);
|
||||
return await response.json();
|
||||
}
|
||||
@@ -1,9 +1,23 @@
|
||||
<script setup lang="ts">
|
||||
import { defineAsyncComponent } from "vue";
|
||||
import { getMetadata } from "@/api/meta";
|
||||
import type { Metadata } from "@/types";
|
||||
import { defineAsyncComponent, onBeforeMount, ref } from "vue";
|
||||
|
||||
const metadata = ref<Metadata|null>(null);
|
||||
|
||||
const LangInput = defineAsyncComponent(
|
||||
() => import("@/components/LangInput.vue"),
|
||||
);
|
||||
|
||||
function fetchMetadata() {
|
||||
void getMetadata()
|
||||
.then((data) => {
|
||||
metadata.value = data;
|
||||
setTimeout(fetchMetadata, 600000);
|
||||
});
|
||||
}
|
||||
|
||||
onBeforeMount(fetchMetadata);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -19,6 +33,7 @@ const LangInput = defineAsyncComponent(
|
||||
>
|
||||
klemek
|
||||
</a>
|
||||
<span v-if="metadata">- {{ $t("metadata", metadata) }}</span>
|
||||
</p>
|
||||
</aside>
|
||||
</footer>
|
||||
|
||||
@@ -46,3 +46,8 @@ export interface Alert {
|
||||
created: Date;
|
||||
seconds: number;
|
||||
}
|
||||
|
||||
export interface Metadata {
|
||||
tasks: number;
|
||||
lists: number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user