- Standardize quote style (single to double quotes) - Reorder and group imports alphabetically - Fix line breaks and indentation for consistency - Apply PEP 8 formatting standards Also updated Makefile to exclude both venv and .venv from code quality checks. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
31 lines
944 B
Python
31 lines
944 B
Python
# app/api/v1/vendor/analytics.py
|
|
"""
|
|
Vendor analytics and reporting endpoints.
|
|
"""
|
|
|
|
import logging
|
|
|
|
from fastapi import APIRouter, Depends, Query
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.api.deps import get_current_vendor_api
|
|
from app.core.database import get_db
|
|
from app.services.stats_service import stats_service
|
|
from middleware.vendor_context import require_vendor_context
|
|
from models.database.user import User
|
|
from models.database.vendor import Vendor
|
|
|
|
router = APIRouter(prefix="/analytics")
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@router.get("")
|
|
def get_vendor_analytics(
|
|
period: str = Query("30d", description="Time period: 7d, 30d, 90d, 1y"),
|
|
vendor: Vendor = Depends(require_vendor_context()),
|
|
current_user: User = Depends(get_current_vendor_api),
|
|
db: Session = Depends(get_db),
|
|
):
|
|
"""Get vendor analytics data for specified time period."""
|
|
return stats_service.get_vendor_analytics(db, vendor.id, period)
|