Skip to content

Commit

Permalink
Fetch workflow and delivery type from order
Browse files Browse the repository at this point in the history
  • Loading branch information
islean committed Jan 21, 2025
1 parent c8d749f commit 27bd592
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from cg.constants.constants import CustomerId
from cg.constants.sequencing import SeqLibraryPrepCategory
from cg.models.orders.sample_base import SexEnum, StatusEnum
from cg.services.orders.constants import ORDER_TYPE_WORKFLOW_MAP
from cg.services.orders.lims_service.service import OrderLimsService
from cg.services.orders.storing.constants import MAF_ORDER_ID
from cg.services.orders.storing.service import StoreOrderService
Expand Down Expand Up @@ -82,8 +83,8 @@ def _create_db_case(self, order: FastqOrder, db_order: Order) -> Case:
"""Return a Case database object."""
priority: str = order.samples[0].priority
case: Case = self.status_db.add_case(
data_analysis=Workflow.RAW_DATA,
data_delivery=DataDelivery.FASTQ,
data_analysis=ORDER_TYPE_WORKFLOW_MAP[order.order_type],
data_delivery=DataDelivery(order.delivery_type),
name=str(db_order.ticket_id),
priority=priority,
ticket=str(db_order.ticket_id),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from cg.constants import DataDelivery, SexOptions, Workflow
from cg.models.orders.sample_base import StatusEnum
from cg.services.orders.constants import ORDER_TYPE_WORKFLOW_MAP
from cg.services.orders.lims_service.service import OrderLimsService
from cg.services.orders.storing.service import StoreOrderService
from cg.services.orders.validation.workflows.microbial_fastq.models.order import MicrobialFastqOrder
Expand Down Expand Up @@ -46,7 +47,7 @@ def store_order_data_in_status_db(self, order: MicrobialFastqOrder) -> list[Samp
with self.status_db.session.no_autoflush:
for sample in order.samples:
case: Case = self._create_db_case_for_sample(
sample=sample, customer=db_order.customer, ticket_id=str(db_order.ticket_id)
sample=sample, customer=db_order.customer, order=order
)
db_sample: Sample = self._create_db_sample(
sample=sample,
Expand All @@ -73,16 +74,16 @@ def _create_db_order(self, order: MicrobialFastqOrder) -> Order:
return self.status_db.add_order(customer=customer, ticket_id=ticket_id)

def _create_db_case_for_sample(
self, sample: MicrobialFastqSample, customer: Customer, ticket_id: str
self, sample: MicrobialFastqSample, customer: Customer, order: MicrobialFastqOrder
) -> Case:
"""Return a Case database object for a MicrobialFastqSample."""
case_name: str = f"{sample.name}-case"
case: Case = self.status_db.add_case(
data_analysis=Workflow.RAW_DATA,
data_delivery=DataDelivery.FASTQ,
data_analysis=ORDER_TYPE_WORKFLOW_MAP[order.order_type],
data_delivery=DataDelivery(order.delivery_type),
name=case_name,
priority=sample.priority,
ticket=ticket_id,
ticket=str(order._generated_ticket_id),
)
case.customer = customer
return case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from cg.constants import DataDelivery, Workflow
from cg.models.orders.sample_base import StatusEnum
from cg.services.orders.constants import ORDER_TYPE_WORKFLOW_MAP
from cg.services.orders.lims_service.service import OrderLimsService
from cg.services.orders.storing.service import StoreOrderService
from cg.services.orders.validation.workflows.pacbio_long_read.models.order import PacbioOrder
Expand Down Expand Up @@ -77,16 +78,16 @@ def _create_db_order(self, order: PacbioOrder) -> Order:
return self.status_db.add_order(customer=customer, ticket_id=ticket_id)

def _create_db_case_for_sample(
self, sample: PacbioSample, customer: Customer, ticket_id: str
self, sample: PacbioSample, customer: Customer, order: PacbioOrder
) -> Case:
"""Return a Case database object for a PacbioSample."""
case_name: str = f"{sample.name}-case"
case: Case = self.status_db.add_case(
data_analysis=Workflow.RAW_DATA,
data_delivery=DataDelivery.BAM,
data_analysis=ORDER_TYPE_WORKFLOW_MAP[order.order_type],
data_delivery=DataDelivery(order.delivery_type),
name=case_name,
priority=sample.priority,
ticket=ticket_id,
ticket=str(order._generated_ticket_id),
)
case.customer = customer
return case
Expand Down

0 comments on commit 27bd592

Please sign in to comment.