You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
be-optimumoh/src/calculation_budget_constrains/router.py

44 lines
1.3 KiB
Python

from typing import Annotated, Dict, List, Optional
from fastapi import APIRouter, HTTPException, status
from fastapi.params import Query
from src.auth.service import Token
from src.calculation_budget_constrains.schema import BudgetContraintQuery
from src.calculation_target_reliability.service import get_simulation_results
from src.config import TC_RBD_ID
from src.database.core import CollectorDbSession, DbSession
from src.models import StandardResponse
from .service import get_all_budget_constrains
router = APIRouter()
@router.get("/{session_id}", response_model=StandardResponse[Dict])
async def get_target_reliability(
db_session: DbSession,
token: Token,
session_id: str,
collector_db: CollectorDbSession,
params: Annotated[BudgetContraintQuery, Query()],
):
"""Get all scope pagination."""
cost_threshold = params.cost_threshold
results = await get_simulation_results(
simulation_id = TC_RBD_ID,
token=token
)
results, consequence = await get_all_budget_constrains(
db_session=db_session, session_id=session_id, cost_threshold=cost_threshold, simulation_result=results, collector_db=collector_db
)
return StandardResponse(
data={
"results": results,
"consequence": consequence
},
message="Data retrieved successfully",
)