Skip to content

Commit

Permalink
(Streamline delivery) Fetch both completed and delivered in order sum…
Browse files Browse the repository at this point in the history
…mary (#3090) (patch)

### Fixed

- Both completed and delivered counts are reported in the order status summary.
  • Loading branch information
islean authored Apr 8, 2024
1 parent 8193035 commit a8a5748
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 21 deletions.
9 changes: 5 additions & 4 deletions cg/apps/tb/dto/summary_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

class AnalysisSummary(BaseModel):
order_id: int
delivered: int | None = None
running: int | None = None
cancelled: int | None = None
failed: int | None = None
cancelled: int
completed: int
delivered: int
failed: int
running: int


class SummariesResponse(BaseModel):
Expand Down
15 changes: 8 additions & 7 deletions cg/services/orders/order_status_service/dto/order_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
class OrderSummary(BaseModel):
order_id: int = Field(exclude=True)
total: int
delivered: int | None = None
running: int | None = None
cancelled: int | None = None
failed: int | None = None
in_sequencing: int | None = None
in_lab_preparation: int | None = None
not_received: int | None = None
cancelled: int
completed: int
delivered: int
failed: int
in_lab_preparation: int
in_sequencing: int
not_received: int
running: int
1 change: 1 addition & 0 deletions cg/services/orders/order_status_service/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def create_order_summary(
delivered=analysis_summary.delivered,
cancelled=analysis_summary.cancelled,
failed=analysis_summary.failed,
completed=analysis_summary.completed,
)


Expand Down
4 changes: 3 additions & 1 deletion tests/server/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ def client(app: Flask) -> Generator[FlaskClient, None, None]:
def analysis_summary():
return AnalysisSummary(
order_id=1,
total=2,
cancelled=0,
completed=1,
running=0,
delivered=1,
failed=1,
)
25 changes: 20 additions & 5 deletions tests/server/endpoints/test_orders_endpoint.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from http import HTTPStatus

import mock.mock
from flask.testing import FlaskClient
import pytest
from flask.testing import FlaskClient

from cg.apps.tb import TrailblazerAPI
from cg.apps.tb.dto.summary_response import AnalysisSummary
Expand All @@ -29,7 +29,6 @@ def test_orders_endpoint(
limit: int | None,
workflow: str,
expected_orders: int,
analysis_summary,
):
"""Tests that orders are returned from the orders endpoint"""
# GIVEN a store with three orders, two of which are MIP-DNA and the last is BALSAMIC
Expand All @@ -40,9 +39,25 @@ def test_orders_endpoint(
TrailblazerAPI,
"get_summaries",
return_value=[
AnalysisSummary(order_id=order.id),
AnalysisSummary(order_id=order_another.id),
AnalysisSummary(order_id=order_balsamic.id),
AnalysisSummary(
order_id=order.id, cancelled=0, completed=1, delivered=0, failed=0, running=0
),
AnalysisSummary(
order_id=order_another.id,
cancelled=0,
completed=1,
delivered=0,
failed=0,
running=0,
),
AnalysisSummary(
order_id=order_balsamic.id,
cancelled=0,
completed=1,
delivered=0,
failed=0,
running=0,
),
],
):
response = client.get(endpoint, query_string={"pageSize": limit, "workflow": workflow})
Expand Down
15 changes: 11 additions & 4 deletions tests/services/orders/order_status_service/conftest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from datetime import datetime
from mock import Mock

import pytest
from cg.apps.tb.dto.summary_response import AnalysisSummary
from mock import Mock

from cg.services.orders.order_status_service.order_summary_service import OrderSummaryService
from cg.apps.tb.dto.summary_response import AnalysisSummary
from cg.services.orders.order_status_service.order_summary_service import (
OrderSummaryService,
)
from cg.store.models import Case, Customer, Order, Sample
from cg.store.store import Store
from tests.store_helpers import StoreHelpers
Expand All @@ -12,7 +15,11 @@
@pytest.fixture
def summary_service(store: Store, order: Order):
service = OrderSummaryService(analysis_client=Mock(), store=store)
service.analysis_client.get_summaries.return_value = [AnalysisSummary(order_id=order.id)]
service.analysis_client.get_summaries.return_value = [
AnalysisSummary(
order_id=order.id, cancelled=0, completed=1, delivered=0, failed=0, running=0
)
]
return service


Expand Down

0 comments on commit a8a5748

Please sign in to comment.