30 lines
805 B
Python
30 lines
805 B
Python
"""原始样本调试接口。"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from fastapi import APIRouter, Depends, Query
|
|
|
|
from apps.api.auth import require_auth
|
|
from packages.config import get_settings
|
|
from packages.db import Repository
|
|
|
|
router = APIRouter(tags=["samples"], dependencies=[Depends(require_auth)])
|
|
|
|
|
|
@router.get("/samples/recent")
|
|
def recent_samples(limit: int = Query(default=20, ge=1, le=200)) -> dict:
|
|
s = get_settings()
|
|
repo = Repository(s.db_path)
|
|
try:
|
|
rows = repo.conn.execute(
|
|
"""
|
|
SELECT * FROM option_quotes
|
|
ORDER BY ts_ms DESC, id DESC
|
|
LIMIT ?
|
|
""",
|
|
(limit,),
|
|
).fetchall()
|
|
return {"items": [dict(r) for r in rows]}
|
|
finally:
|
|
repo.close()
|