Skip to content

Commit

Permalink
logging
Browse files Browse the repository at this point in the history
  • Loading branch information
seallard committed Aug 6, 2024
1 parent c692fe0 commit 4b33915
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions genotype_api/services/endpoint_services/plate_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,22 @@
from pydantic import EmailStr

from genotype_api.constants import Types
from genotype_api.database.filter_models.plate_models import PlateSignOff, PlateOrderParams
from genotype_api.database.filter_models.plate_models import (
PlateSignOff,
PlateOrderParams,
)
from genotype_api.database.models import Plate, Analysis, User, Sample
from genotype_api.dto.plate import PlateResponse, UserOnPlate, AnalysisOnPlate, SampleStatus
from genotype_api.exceptions import PlateNotFoundError, UserNotFoundError, PlateExistsError
from genotype_api.dto.plate import (
PlateResponse,
UserOnPlate,
AnalysisOnPlate,
SampleStatus,
)
from genotype_api.exceptions import (
PlateNotFoundError,
UserNotFoundError,
PlateExistsError,
)
from genotype_api.file_parsing.excel import GenotypeAnalysis
from genotype_api.file_parsing.files import check_file
from genotype_api.services.endpoint_services.base_service import BaseService
Expand Down Expand Up @@ -85,8 +97,12 @@ def upload_plate(self, file: UploadFile) -> None:
plate_obj = Plate(plate_id=plate_id)
plate: Plate = self.store.create_plate(plate=plate_obj)
new_plate: Plate = self.store.get_plate_by_plate_id(plate_id=plate_id)
analyses: list[Analysis] = list(excel_parser.generate_analyses(plate_id=new_plate.id))
self.store.check_analyses_objects(analyses=analyses, analysis_type=Types.GENOTYPE)
analyses: list[Analysis] = list(
excel_parser.generate_analyses(plate_id=new_plate.id)
)
self.store.check_analyses_objects(
analyses=analyses, analysis_type=Types.GENOTYPE
)
self.store.create_analyses_samples(analyses=analyses)
for analysis in analyses:
self.store.create_analysis(analysis=analysis)
Expand All @@ -97,7 +113,11 @@ def upload_plate(self, file: UploadFile) -> None:
self.store.refresh_plate(plate=plate)

def update_plate_sign_off(
self, plate_id: int, user_email: EmailStr, method_document: str, method_version: str
self,
plate_id: int,
user_email: EmailStr,
method_document: str,
method_version: str,
) -> PlateResponse:
plate: Plate = self.store.get_plate_by_id(plate_id=plate_id)
if not plate:
Expand Down Expand Up @@ -131,7 +151,9 @@ def delete_plate(self, plate_id) -> list[int]:
plate = self.store.get_plate_by_id(plate_id=plate_id)
if not plate:
raise PlateNotFoundError
analyses: list[Analysis] = self.store.get_analyses_by_plate_id(plate_id=plate_id)
analyses: list[Analysis] = self.store.get_analyses_by_plate_id(
plate_id=plate_id
)
analysis_ids: list[int] = [analyse.id for analyse in analyses]
for analysis in analyses:
self.store.delete_analysis(analysis=analysis)
Expand Down

0 comments on commit 4b33915

Please sign in to comment.