-
Notifications
You must be signed in to change notification settings - Fork 3
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 logic for differing SLA for order tickets #4274
base: master
Are you sure you want to change the base?
Changes from all commits
bf2f101
502704f
5fb1301
60f253f
19173a5
b1a52f6
90a06ac
b6e0f93
d9e45ca
f069445
391e145
f93cb7a
3c733ac
3f734b2
120af4f
bcf28b9
c26fec4
87b9b7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
from cg.constants.priority import TrailblazerPriority | ||
from cg.constants.priority import Priority, TrailblazerPriority | ||
|
||
MAP_TO_TRAILBLAZER_PRIORITY: dict[int, TrailblazerPriority] = { | ||
0: TrailblazerPriority.LOW, | ||
1: TrailblazerPriority.NORMAL, | ||
2: TrailblazerPriority.HIGH, | ||
3: TrailblazerPriority.EXPRESS, | ||
4: TrailblazerPriority.NORMAL, | ||
MAP_TO_TRAILBLAZER_PRIORITY: dict[Priority, TrailblazerPriority] = { | ||
Priority.research: TrailblazerPriority.LOW, | ||
Priority.standard: TrailblazerPriority.NORMAL, | ||
Priority.clinical_trials: TrailblazerPriority.NORMAL, | ||
Priority.priority: TrailblazerPriority.HIGH, | ||
Priority.express: TrailblazerPriority.EXPRESS, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
import logging | ||
from datetime import date | ||
from pathlib import Path | ||
from tempfile import TemporaryDirectory | ||
from typing import Any | ||
|
||
from cg.clients.freshdesk.freshdesk_client import FreshdeskClient | ||
from cg.clients.freshdesk.models import TicketCreate, TicketResponse | ||
from cg.meta.orders.utils import get_ticket_status, get_ticket_tags | ||
from cg.constants.priority import Priority | ||
from cg.meta.orders.utils import get_due_by_date, get_ticket_status, get_ticket_tags | ||
from cg.models.orders.constants import OrderType | ||
from cg.services.orders.constants import ORDER_TYPE_WORKFLOW_MAP | ||
from cg.services.orders.validation.models.order import Order | ||
from cg.services.orders.validation.models.order_with_cases import OrderWithCases | ||
from cg.services.orders.validation.models.order_with_samples import OrderWithSamples | ||
from cg.store.models import Customer, Sample | ||
from cg.store.models import Case, Customer, Sample | ||
from cg.store.store import Store | ||
|
||
LOG = logging.getLogger(__name__) | ||
|
@@ -41,6 +42,9 @@ def create_ticket( | |
tags: list[str] = get_ticket_tags(order=order, order_type=order_type) | ||
status: int = get_ticket_status(order=order) | ||
|
||
order_priority: Priority = self._get_max_case_priority(order=order) | ||
deadline_date: date = get_due_by_date(priority=order_priority) | ||
|
||
with TemporaryDirectory() as temp_dir: | ||
attachments: Path = self.create_attachment_file(order=order, temp_dir=temp_dir) | ||
|
||
|
@@ -57,6 +61,8 @@ def create_ticket( | |
}, | ||
attachments=[], | ||
status=status, | ||
due_by=deadline_date, | ||
fr_due_by=deadline_date, | ||
) | ||
ticket_response: TicketResponse = self.client.create_ticket( | ||
ticket=freshdesk_ticket, attachments=[attachments] | ||
|
@@ -217,3 +223,21 @@ def create_case_xml_sample_list(self, order, message: str) -> str: | |
message=message, comment=sample.comment | ||
) | ||
return message | ||
|
||
def _get_max_case_priority(self, order: Order) -> Priority: | ||
"""Get max case priority for a given order.""" | ||
priority_list: list[Priority] = [] | ||
|
||
if isinstance(order, OrderWithCases): | ||
for index, new_case in order.enumerated_new_cases: | ||
priority_list.append(Priority[new_case.priority]) | ||
|
||
for index, case in order.enumerated_existing_cases: | ||
case: Case = self.status_db.get_case_by_internal_id(case.internal_id) | ||
beatrizsavinhas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
priority_list.append(case.priority) | ||
|
||
if isinstance(order, OrderWithSamples): | ||
for sample in order.samples: | ||
priority_list.append(Priority[sample.priority]) | ||
|
||
return max(priority_list) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given how the Priority IntEnum is set up, I think this will always return clinical trials priority if any such sample/case is present. Is that how we want it to be? (Priority.clinical_trials = 4 > 3 = Priority.express) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are completely right! I'll test changing the priorities and see if it works. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we not get exceptions where they were not allowed equal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No... It must have been a problem with the test setup at the time. After testing both in postman and in stage, it works fine! See the tests that I executed above - #4274 (comment).