30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
from fastapi import APIRouter
|
|
from typing import Optional
|
|
from cryptoai.utils.db_manager import get_db_manager
|
|
from fastapi import Depends
|
|
from pydantic import BaseModel
|
|
from cryptoai.routes.user import get_current_user
|
|
|
|
|
|
class AnalysisHistoryRequest(BaseModel):
|
|
symbol: str
|
|
content: str
|
|
timeframe: Optional[str] = None
|
|
type: str
|
|
|
|
router = APIRouter()
|
|
|
|
@router.post("/analysis_history")
|
|
async def analysis_history(request: AnalysisHistoryRequest,
|
|
current_user: dict = Depends(get_current_user)):
|
|
|
|
get_db_manager().analysis_history_manager.add_analysis_history(current_user["id"], request.type, request.symbol, request.content, request.timeframe)
|
|
|
|
return {"message": "ok"}
|
|
|
|
@router.get("/analysis_histories")
|
|
async def get_analysis_histories(current_user: dict = Depends(get_current_user),
|
|
limit: int = 10,
|
|
offset: int = 0):
|
|
history = get_db_manager().analysis_history_manager.get_user_analysis_history(current_user["id"], limit=limit, offset=offset)
|
|
return history |