Initial commit

This commit is contained in:
root
2026-04-29 08:17:35 +00:00
commit ef55253cbd
49 changed files with 3073 additions and 0 deletions

24
app/utils/stats.py Normal file
View File

@@ -0,0 +1,24 @@
import time
import logging
from typing import Optional
from app.database import pool
logger = logging.getLogger(__name__)
async def track_usage(
user_id: str,
action: str,
store_id: Optional[str] = None,
tokens: int = 0,
duration: float = 0
):
try:
async with pool.acquire() as conn:
await conn.execute(
"""INSERT INTO usage_stats
(user_id, store_id, action, tokens, duration)
VALUES ($1, $2, $3, $4, $5)""",
user_id, store_id, action, tokens, round(duration, 3)
)
except Exception as e:
logger.error(f"Tracking Fehler: {e}")