feat: add where are more items problem
This commit is contained in:
@@ -3,10 +3,15 @@ from fastapi import APIRouter, HTTPException
|
||||
from app.problems.grade_1.join_pictures_with_quantity import (
|
||||
join_pictures_with_quantity,
|
||||
)
|
||||
from app.problems.grade_1.where_are_more_items import where_are_more_items
|
||||
from app.schemas.grade_1.join_pictures_with_quantity import (
|
||||
JoinPicturesWithQuantityProblem,
|
||||
JoinPicturesWithQuantityRequest,
|
||||
)
|
||||
from app.schemas.grade_1.where_are_more_items import (
|
||||
WhereAreMoreItemsProblem,
|
||||
WhereAreMoreItemsRequest,
|
||||
)
|
||||
|
||||
router = APIRouter(prefix="/grade_1", tags=["Grade 1"])
|
||||
|
||||
@@ -30,3 +35,24 @@ def create_join_pictures_with_quantity_problem(
|
||||
)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
|
||||
|
||||
@router.post(
|
||||
"/where_are_more_items",
|
||||
response_model=WhereAreMoreItemsProblem,
|
||||
)
|
||||
def create_where_are_more_items_problem(
|
||||
request: WhereAreMoreItemsRequest,
|
||||
) -> dict:
|
||||
try:
|
||||
return where_are_more_items(
|
||||
available_pictures=[
|
||||
picture.model_dump() for picture in request.available_pictures
|
||||
],
|
||||
comparison_count=request.comparison_count,
|
||||
min_quantity=request.min_quantity,
|
||||
max_quantity=request.max_quantity,
|
||||
seed=request.seed,
|
||||
)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
|
||||
Reference in New Issue
Block a user