Add admin features, responsive UI, user reviews, visit stats, and channel-colored markers
- Admin: video management with Google Maps match status, manual restaurant mapping, restaurant remap on name change - Admin: user management tab with favorites/reviews detail - Admin: channel deletion fix for IDs with slashes - Frontend: responsive mobile layout (map top, list bottom, 2-row header) - Frontend: channel-colored map markers with legend - Frontend: my reviews list, favorites toggle, visit counter overlay - Frontend: force light mode for dark theme devices - Backend: visit tracking (site_visits table), user reviews endpoint - Backend: bulk transcript/extract streaming, geocode key fixes - Nginx config for production deployment Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
43
backend/api/routes/stats.py
Normal file
43
backend/api/routes/stats.py
Normal file
@@ -0,0 +1,43 @@
|
||||
"""Site visit statistics API."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi import APIRouter
|
||||
|
||||
from core.db import conn
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.post("/visit")
|
||||
def record_visit():
|
||||
"""Record a page visit. Increments today's count."""
|
||||
sql = """
|
||||
MERGE INTO site_visits sv
|
||||
USING (SELECT TRUNC(SYSDATE) AS d FROM dual) src
|
||||
ON (sv.visit_date = src.d)
|
||||
WHEN MATCHED THEN UPDATE SET sv.visit_count = sv.visit_count + 1
|
||||
WHEN NOT MATCHED THEN INSERT (visit_date, visit_count) VALUES (src.d, 1)
|
||||
"""
|
||||
with conn() as c:
|
||||
c.cursor().execute(sql)
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
@router.get("/visits")
|
||||
def get_visits():
|
||||
"""Return today's visit count and all-time total."""
|
||||
sql_today = """
|
||||
SELECT NVL(visit_count, 0) FROM site_visits WHERE visit_date = TRUNC(SYSDATE)
|
||||
"""
|
||||
sql_total = """
|
||||
SELECT NVL(SUM(visit_count), 0) FROM site_visits
|
||||
"""
|
||||
with conn() as c:
|
||||
cur = c.cursor()
|
||||
cur.execute(sql_today)
|
||||
row = cur.fetchone()
|
||||
today = int(row[0]) if row else 0
|
||||
cur.execute(sql_total)
|
||||
total = int(cur.fetchone()[0])
|
||||
return {"today": today, "total": total}
|
||||
Reference in New Issue
Block a user