85c4cfb9e8
- Add image_extractor, pdf_downloader, pi_client, trends services - Add shared utils module - Refactor summarizer, embedder, routes for cleaner separation - Update tests to match new service structure
34 lines
849 B
Python
34 lines
849 B
Python
"""趋势看板路由 — 论文统计图表页面和数据 API。"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from fastapi import APIRouter, Depends, Request
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.database import get_db
|
|
from app.services.trends import get_trends_data
|
|
from app.utils import templates, today_str
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/trends")
|
|
def trends_page(request: Request, db: Session = Depends(get_db)):
|
|
"""趋势看板页面。"""
|
|
stats = get_trends_data(db)
|
|
return templates.TemplateResponse(
|
|
request,
|
|
"trends.html",
|
|
{
|
|
"page_title": "趋势看板",
|
|
"stats": stats,
|
|
"today": today_str(),
|
|
},
|
|
)
|
|
|
|
|
|
@router.get("/api/stats/trends")
|
|
def trends_api(db: Session = Depends(get_db)):
|
|
"""趋势数据 JSON API。"""
|
|
return get_trends_data(db)
|