from fastapi import APIRouter from loguru import logger from app.controllers.algorithms.graph_coloring import get_graph_coloring from app.controllers.algorithms.meeting_attendee_recommendation import ( build_recommendations, ) from app.models.domain.algorithms import GraphColoringRequest, GraphColoringResponse from app.models.domain.algorithms import ( AttendeesRecommendationRequest, AttendeesRecommendationResponse, ) router = APIRouter() @router.get("/status") async def get_living_condition(): return {"message": "alive"} @router.post("/graph-coloring", response_model=GraphColoringResponse) async def get_graph_coloring_result(graph: GraphColoringRequest): is_solvable, colored = await get_graph_coloring(graph.graph) solution = {"is_solvable": is_solvable, "colored": colored} return solution @router.post( "/attendees-recommendation", response_model=AttendeesRecommendationResponse ) async def get_recommended(meeting_info: AttendeesRecommendationRequest): try: res = await build_recommendations( meeting_info.companyId, meeting_info.initiatorId ) except Exception as e: logger.error(e) return {"code": 500, "message": "Recommend failure."} else: return {"code": 200, "message": "success", "data": {"userIdList": res}}