Skip to content

Commit

Permalink
Fix query
Browse files Browse the repository at this point in the history
  • Loading branch information
islean committed Oct 10, 2024
1 parent cad5ac6 commit 68fb8bd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion cg/store/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
from sqlalchemy import and_, func
from sqlalchemy.orm import Query, Session

from cg.store.models import Analysis, Application, ApplicationLimitations, ApplicationVersion
from cg.store.models import (
Analysis,
Application,
ApplicationLimitations,
ApplicationVersion,
)
from cg.store.models import Base as ModelBase
from cg.store.models import (
Case,
Expand Down Expand Up @@ -74,6 +79,12 @@ def _get_join_sample_family_query(self) -> Query:
"""Return a join sample case relationship query."""
return self._get_query(table=Sample).join(Case.links).join(CaseSample.sample)

def _get_join_sample_case_order_query(self) -> Query:
"""Return a join sample case relationship query."""
return (
self._get_query(table=Sample).join(Case.links).join(CaseSample.sample).join(Case.orders)
)

def _get_join_sample_application_version_query(self) -> Query:
"""Return join sample to application version query."""
return (
Expand Down
2 changes: 1 addition & 1 deletion cg/store/crud/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def get_customer_id_from_ticket(self, ticket: str) -> str:
def get_samples_from_ticket(self, ticket: str) -> list[Sample]:
"""Returns the samples related to given ticket."""
return apply_order_filters(
orders=self._get_join_sample_family_query().join(Case.orders),
orders=self._get_join_sample_case_order_query(),
filters=[OrderFilter.BY_TICKET_ID],
ticket_id=int(ticket),
).all()
Expand Down

0 comments on commit 68fb8bd

Please sign in to comment.