feat: get stocks
This commit is contained in:
14
main.py
14
main.py
@@ -4,17 +4,21 @@ from typing import Annotated
|
||||
from celery.result import AsyncResult
|
||||
from fastapi import FastAPI, Depends, HTTPException
|
||||
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from starlette import status
|
||||
from starlette.responses import JSONResponse
|
||||
|
||||
import backend.config
|
||||
from backend.session import get_session
|
||||
from background import taskiq_broker
|
||||
from buffer.core import TasksBuffer
|
||||
from schemas.general import *
|
||||
import background.tasks
|
||||
from updaters.stocks_updater import StocksUpdater
|
||||
|
||||
auth_schema = HTTPBearer()
|
||||
buffer = TasksBuffer()
|
||||
SessionDependency = Annotated[AsyncSession, Depends(get_session)]
|
||||
|
||||
|
||||
async def check_auth(token: Annotated[HTTPAuthorizationCredentials, Depends(auth_schema)]):
|
||||
@@ -117,3 +121,13 @@ def get_status(task_id):
|
||||
"task_result": task_result.result
|
||||
}
|
||||
return JSONResponse(result)
|
||||
|
||||
|
||||
@app.get('/marketplace/{marketplace_id}/stocks')
|
||||
async def get_marketplace_stocks(
|
||||
marketplace_id: int,
|
||||
session: SessionDependency,
|
||||
only_available: bool = False
|
||||
):
|
||||
updater = StocksUpdater(session)
|
||||
return await updater.get_all_stocks_for_marketplace(int(marketplace_id), only_available)
|
||||
|
||||
Reference in New Issue
Block a user