File size: 1,644 Bytes
7a511fb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bfb0701
 
 
 
 
 
7a511fb
 
bfb0701
 
 
7a511fb
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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)