Files
ai_agent/backend/app/api/routes/v1/admin_stats.py
T
furyhawk 8351e73d39 feat: add Zustand stores for conversation, file preview, sidebar, theme, and knowledge base selection
- Implemented `conversation-store` for managing conversations and messages.
- Created `file-preview-store` to handle file preview state.
- Added `sidebar-store` for sidebar visibility management.
- Developed `theme-store` for theme persistence and management.
- Introduced `kb-selection-store` for managing active knowledge base selections with persistence.

chore: define API and chat types

- Added types for API responses, authentication, chat messages, conversations, and projects.
- Defined interfaces for various entities including users, sessions, and message ratings.

build: configure TypeScript and testing setup

- Set up `tsconfig.json` for TypeScript configuration.
- Created `vitest.config.ts` for testing configuration with Vitest.
- Added `vitest.setup.ts` for global test setup including mocks for Next.js router and media queries.
- Configured Vercel deployment settings in `vercel.json`.
2026-06-11 16:54:43 +08:00

38 lines
1.1 KiB
Python

"""Admin observability — workspace stats + Stripe event log."""
from typing import Any
from fastapi import APIRouter, Query
from app.api.deps import AdminSvc, CurrentAdmin
from app.schemas.admin import AdminStats, StripeEventList, StripeEventRead
router = APIRouter()
@router.get("/stats", response_model=AdminStats)
async def get_admin_stats(
service: AdminSvc,
_user: CurrentAdmin,
) -> Any:
"""Aggregate workspace metrics. Billing fields are 0 when billing is
disabled in the deployment."""
return await service.workspace_stats()
@router.get("/stripe-events", response_model=StripeEventList)
async def list_stripe_events(
service: AdminSvc,
_user: CurrentAdmin,
skip: int = Query(0, ge=0),
limit: int = Query(50, ge=1, le=200),
) -> Any:
"""List recent Stripe webhook events from the idempotency log.
Best-effort: returns empty list when the StripeEvent table doesn't exist
(billing disabled in this deployment).
"""
rows, total = await service.list_stripe_events(skip=skip, limit=limit)
items = [StripeEventRead.model_validate(row) for row in rows]
return StripeEventList(items=items, total=total)