Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add order status service #2965

Merged
merged 40 commits into from
Feb 28, 2024
Merged

Add order status service #2965

merged 40 commits into from
Feb 28, 2024

Conversation

seallard
Copy link
Contributor

@seallard seallard commented Feb 20, 2024

Description

Closes Clinical-Genomics/streamline-delivery#35.

Add service providing the following information for orders

  • Number of cases
  • Number of cases with samples in lab prep
  • Number of cases with samples in sequencing
  • Number of running analyses
  • Number of failed analyses
  • Number of delivered analyses
  • Number of cancelled analyses

Blocked by https://github.com/Clinical-Genomics/servers/pull/1286

Added

  • Status summaries to response from /orders

This version is a

  • MINOR - when you add functionality in a backwards compatible manner

@seallard seallard changed the title Add query param Add summary to orders Feb 20, 2024
@Clinical-Genomics Clinical-Genomics deleted a comment from sonarqubecloud bot Feb 21, 2024
@seallard seallard marked this pull request as ready for review February 21, 2024 11:57
@seallard seallard requested a review from a team as a code owner February 21, 2024 11:57
Copy link
Contributor

@islean islean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks nice! 🔥

cg/apps/tb/api.py Outdated Show resolved Hide resolved
cg/apps/tb/dto/summary_response.py Outdated Show resolved Hide resolved
cg/server/dto/orders/orders_request.py Outdated Show resolved Hide resolved
cg/services/order_service/utils.py Outdated Show resolved Hide resolved
cg/store/crud/read.py Outdated Show resolved Hide resolved
cg/store/filters/status_order_filters.py Outdated Show resolved Hide resolved
cg/store/filters/status_order_filters.py Show resolved Hide resolved
cg/store/filters/status_order_filters.py Outdated Show resolved Hide resolved
@islean
Copy link
Contributor

islean commented Feb 21, 2024

Might be nice with a test for the summary?

@seallard
Copy link
Contributor Author

Might be nice with a test for the summary?

Yes, I want to add one! I would have to mock the reply from trailblazer. Will look into it, might be too messy due how things are instantiated but would be nice

@seallard seallard changed the title Add summary to orders Add order status summary service Feb 26, 2024
@seallard seallard changed the title Add order status summary service Add order status service Feb 27, 2024
Copy link
Contributor

@islean islean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Probably should test performance before merging though

cg/server/dto/orders/orders_request.py Outdated Show resolved Hide resolved
cg/services/orders/order_service/utils.py Show resolved Hide resolved
cg/services/orders/order_service/utils.py Outdated Show resolved Hide resolved
cg/services/orders/order_status_service/utils.py Outdated Show resolved Hide resolved
cg/services/orders/order_status_service/utils.py Outdated Show resolved Hide resolved
cg/services/orders/order_status_service/utils.py Outdated Show resolved Hide resolved
cg/services/orders/order_status_service/utils.py Outdated Show resolved Hide resolved
cg/services/orders/order_status_service/utils.py Outdated Show resolved Hide resolved
cg/store/filters/status_order_filters.py Show resolved Hide resolved
Copy link
Contributor

@Vince-janv Vince-janv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found one potential bug. Might need a small technical refinement for it

cg/services/orders/order_status_service/utils.py Outdated Show resolved Hide resolved
cg/services/orders/order_service/utils.py Show resolved Hide resolved
@clingen-sthlm clingen-sthlm temporarily deployed to stage February 27, 2024 15:43 Inactive
@clingen-sthlm clingen-sthlm temporarily deployed to stage February 27, 2024 16:03 Inactive
@clingen-sthlm clingen-sthlm temporarily deployed to stage February 27, 2024 16:12 Inactive
@seallard
Copy link
Contributor Author

seallard commented Feb 27, 2024

Tested in stage. Performance seems OK even when retrieving summaries for 50 orders at a time. Will leave optimization for later.

time curl 'https://cg-statusdb-stage.scilifelab.se/api/v1/orders?includeSummary=true&limit=5' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:123.0) Gecko/20100101 Firefox/123.0' -H 'Accept: application/json, text/plain, */*' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate, br' -H 'Referer: https://cigrid-stage.scilifelab.se/' -H 'Authorization: Bearer token' -H 'Origin: https://cigrid-stage.scilifelab.se' -H 'Connection: keep-alive' -H 'Sec-Fetch-Dest: empty' -H 'Sec-Fetch-Mode: cors' -H 'Sec-Fetch-Site: same-site' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'TE: trailers'
{
  "orders": [
    {
      "customer_id": "cust139",
      "order_date": "2024-01-30",
      "order_id": 1,
      "summary": {
        "cancelled": 0,
        "delivered": 0,
        "failed": 0,
        "in_preparation": 1,
        "in_sequencing": 1,
        "order_id": 1,
        "running": 0,
        "total": 1
      },
      "ticket_id": 124515,
      "workflow": "mip-dna"
    },
    {
      "customer_id": "cust002",
      "order_date": "2024-01-30",
      "order_id": 2,
      "summary": {
        "cancelled": 0,
        "delivered": 1,
        "failed": 2,
        "in_preparation": 0,
        "in_sequencing": 0,
        "order_id": 2,
        "running": 0,
        "total": 1
      },
      "ticket_id": 587841,
      "workflow": "balsamic"
    },
    {
      "customer_id": "cust087",
      "order_date": "2024-01-30",
      "order_id": 3,
      "summary": {
        "cancelled": 0,
        "delivered": 1,
        "failed": 0,
        "in_preparation": 0,
        "in_sequencing": 0,
        "order_id": 3,
        "running": 0,
        "total": 1
      },
      "ticket_id": 772082,
      "workflow": "balsamic"
    },
    {
      "customer_id": "cust003",
      "order_date": "2024-01-30",
      "order_id": 4,
      "summary": {
        "cancelled": 0,
        "delivered": 3,
        "failed": 0,
        "in_preparation": 0,
        "in_sequencing": 0,
        "order_id": 4,
        "running": 0,
        "total": 1
      },
      "ticket_id": 512736,
      "workflow": "mip-dna"
    },
    {
      "customer_id": "cust002",
      "order_date": "2024-01-31",
      "order_id": 5,
      "summary": {
        "cancelled": 0,
        "delivered": 0,
        "failed": 0,
        "in_preparation": 0,
        "in_sequencing": 0,
        "order_id": 5,
        "running": 0,
        "total": 1
      },
      "ticket_id": 755205,
      "workflow": "mip-dna"
    }
  ]
}
curl  -H  -H 'Accept: application/json, text/plain, */*' -H  -H  -H  -H  -H    0.02s user 0.01s system 6% cpu 0.392 total

A case is in lab preparation if any sample still has not been prepared.
A case is in sequencing if all samples have been prepared and at least one sample has not been sequenced yet.
@seallard seallard requested a review from Vince-janv February 28, 2024 09:52
Copy link
Contributor

@Vince-janv Vince-janv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My previous concern has been addressed ⭐

@islean
Copy link
Contributor

islean commented Feb 28, 2024

Tested in stage. Performance seems OK even when retrieving summaries for 50 orders at a time. Will leave optimization for later.

time curl 'https://cg-statusdb-stage.scilifelab.se/api/v1/orders?includeSummary=true&limit=5' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:123.0) Gecko/20100101 Firefox/123.0' -H 'Accept: application/json, text/plain, */*' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate, br' -H 'Referer: https://cigrid-stage.scilifelab.se/' -H 'Authorization: Bearer token' -H 'Origin: https://cigrid-stage.scilifelab.se' -H 'Connection: keep-alive' -H 'Sec-Fetch-Dest: empty' -H 'Sec-Fetch-Mode: cors' -H 'Sec-Fetch-Site: same-site' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'TE: trailers'
{
  "orders": [
    {
      "customer_id": "cust139",
      "order_date": "2024-01-30",
      "order_id": 1,
      "summary": {
        "cancelled": 0,
        "delivered": 0,
        "failed": 0,
        "in_preparation": 1,
        "in_sequencing": 1,
        "order_id": 1,
        "running": 0,
        "total": 1
      },
      "ticket_id": 124515,
      "workflow": "mip-dna"
    },
    {
      "customer_id": "cust002",
      "order_date": "2024-01-30",
      "order_id": 2,
      "summary": {
        "cancelled": 0,
        "delivered": 1,
        "failed": 2,
        "in_preparation": 0,
        "in_sequencing": 0,
        "order_id": 2,
        "running": 0,
        "total": 1
      },
      "ticket_id": 587841,
      "workflow": "balsamic"
    },
    {
      "customer_id": "cust087",
      "order_date": "2024-01-30",
      "order_id": 3,
      "summary": {
        "cancelled": 0,
        "delivered": 1,
        "failed": 0,
        "in_preparation": 0,
        "in_sequencing": 0,
        "order_id": 3,
        "running": 0,
        "total": 1
      },
      "ticket_id": 772082,
      "workflow": "balsamic"
    },
    {
      "customer_id": "cust003",
      "order_date": "2024-01-30",
      "order_id": 4,
      "summary": {
        "cancelled": 0,
        "delivered": 3,
        "failed": 0,
        "in_preparation": 0,
        "in_sequencing": 0,
        "order_id": 4,
        "running": 0,
        "total": 1
      },
      "ticket_id": 512736,
      "workflow": "mip-dna"
    },
    {
      "customer_id": "cust002",
      "order_date": "2024-01-31",
      "order_id": 5,
      "summary": {
        "cancelled": 0,
        "delivered": 0,
        "failed": 0,
        "in_preparation": 0,
        "in_sequencing": 0,
        "order_id": 5,
        "running": 0,
        "total": 1
      },
      "ticket_id": 755205,
      "workflow": "mip-dna"
    }
  ]
}
curl  -H  -H 'Accept: application/json, text/plain, */*' -H  -H  -H  -H  -H    0.02s user 0.01s system 6% cpu 0.392 total

The total seems very off here

@clingen-sthlm clingen-sthlm temporarily deployed to stage February 28, 2024 14:16 Inactive
@clingen-sthlm clingen-sthlm temporarily deployed to stage February 28, 2024 15:02 Inactive
@seallard seallard merged commit b91c2cc into master Feb 28, 2024
6 checks passed
@seallard seallard deleted the add-order-summary branch February 28, 2024 15:09
Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include summaries in response from /orders
4 participants