ipns-eval-poc-backend / src /services /_analysis_service.py
Aryan Jain
implement calculation for adjusted score
bfb0701
from src.repositories import AnalysisRepository
from src.models import AnalysisType
class AnalysisService:
def __init__(self):
self.analysis_repository = AnalysisRepository
async def __aenter__(self):
return self
async def __aexit__(self, exc_type, exc_value, traceback):
pass
async def get_analysis(
self,
evaluation_id: str = None,
analysis_type: AnalysisType = None,
id: str = None,
):
async with self.analysis_repository() as repo:
return await repo.get_analysis(
evaluation_id=evaluation_id, analysis_type=analysis_type, id=id
)
async def create_analysis(
self,
evaluation_id: str,
evaluation_analysis: dict,
analysis_score_type: str = None,
):
async with self.analysis_repository() as repo:
return await repo.create_analysis(
evaluation_id=evaluation_id,
evaluation_analysis=evaluation_analysis,
analysis_score_type=analysis_score_type,
)
async def update_analysis(
self, evaluation_id: str = None, id: str = None, proposal_analysis: dict = None
):
async with self.analysis_repository() as repo:
return await repo.update_analysis(
evaluation_id=evaluation_id, id=id, proposal_analysis=proposal_analysis
)
async def delete_analysis(self, evaluation_id: str = None, id: str = None):
async with self.analysis_repository() as repo:
return await repo.delete_analysis(evaluation_id=evaluation_id, id=id)