feat(admin): Nutzungsstatistik um "mit Websuche" je Nutzer
get_all_usage liefert total_web_searches (Summe aus web_search_usage); Statistik-Tabelle + Gesamtzeile zeigen die neue Spalte "mit Websuche". Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
d738921d25
commit
d74e94e6a4
2 changed files with 7 additions and 1 deletions
|
|
@ -643,7 +643,9 @@ class SQLiteStore(Store):
|
|||
rows = conn.execute(
|
||||
"SELECT u.user_id, COALESCE(usr.display_name, u.user_id) AS display_name,"
|
||||
" SUM(u.requests) AS total_requests, SUM(u.units) AS total_units,"
|
||||
" MAX(u.day) AS last_active"
|
||||
" MAX(u.day) AS last_active,"
|
||||
" COALESCE((SELECT SUM(w.count) FROM web_search_usage w"
|
||||
" WHERE w.user_id = u.user_id), 0) AS total_web_searches"
|
||||
" FROM usage u LEFT JOIN users usr ON usr.id = u.user_id"
|
||||
" GROUP BY u.user_id ORDER BY total_requests DESC",
|
||||
).fetchall()
|
||||
|
|
|
|||
|
|
@ -1826,6 +1826,7 @@ async function loadMetrics() {
|
|||
if (!data.length) { container.innerHTML = '<p class="text-sm text-slate-400 py-4 text-center">Noch keine Nutzungsdaten vorhanden.</p>'; return; }
|
||||
|
||||
const totalReq = data.reduce((s, u) => s + (u.total_requests || 0), 0);
|
||||
const totalWS = data.reduce((s, u) => s + (u.total_web_searches || 0), 0);
|
||||
const maxReq = Math.max(...data.map((u) => u.total_requests || 0), 1);
|
||||
|
||||
const bars = data.map((u) => {
|
||||
|
|
@ -1847,6 +1848,7 @@ async function loadMetrics() {
|
|||
<tr class="text-xs text-slate-500 dark:text-slate-400 border-b border-slate-200 dark:border-slate-700">
|
||||
<th class="text-left px-4 py-2.5">Nutzer</th>
|
||||
<th class="text-right px-4 py-2.5">Anfragen gesamt</th>
|
||||
<th class="text-right px-4 py-2.5">mit Websuche</th>
|
||||
<th class="text-right px-4 py-2.5">Einheiten</th>
|
||||
<th class="text-right px-4 py-2.5">Letzte Aktivität</th>
|
||||
</tr>
|
||||
|
|
@ -1856,6 +1858,7 @@ async function loadMetrics() {
|
|||
<tr class="hover:bg-slate-50 dark:hover:bg-slate-700/40 transition-colors">
|
||||
<td class="px-4 py-2.5 font-medium">${escHtml(u.display_name)}</td>
|
||||
<td class="px-4 py-2.5 text-right font-mono text-xs">${u.total_requests ?? 0}</td>
|
||||
<td class="px-4 py-2.5 text-right font-mono text-xs">${u.total_web_searches ?? 0}</td>
|
||||
<td class="px-4 py-2.5 text-right font-mono text-xs">${u.total_units ?? 0}</td>
|
||||
<td class="px-4 py-2.5 text-right text-xs text-slate-400">${u.last_active || "—"}</td>
|
||||
</tr>`).join("")}
|
||||
|
|
@ -1864,6 +1867,7 @@ async function loadMetrics() {
|
|||
<tr class="text-xs font-semibold text-slate-600 dark:text-slate-300">
|
||||
<td class="px-4 py-2">Gesamt</td>
|
||||
<td class="px-4 py-2 text-right font-mono">${totalReq}</td>
|
||||
<td class="px-4 py-2 text-right font-mono">${totalWS}</td>
|
||||
<td class="px-4 py-2"></td>
|
||||
<td class="px-4 py-2"></td>
|
||||
</tr>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue