Skip to content

Commit

Permalink
Merge pull request #3035 from danswer-ai/freshdesk-nit
Browse files Browse the repository at this point in the history
minor nit
  • Loading branch information
hagen-danswer authored Nov 3, 2024
2 parents 5f5cc9a + 8bcf80a commit 70f703c
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions backend/danswer/connectors/freshdesk/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,28 @@
"to_emails",
}

_SOURCE_NUMBER_TYPE_MAP = {
"1": "Email",
"2": "Portal",
"3": "Phone",
"7": "Chat",
"9": "Feedback Widget",
"10": "Outbound Email",
_SOURCE_NUMBER_TYPE_MAP: dict[int, str] = {
1: "Email",
2: "Portal",
3: "Phone",
7: "Chat",
9: "Feedback Widget",
10: "Outbound Email",
}

_PRIORITY_NUMBER_TYPE_MAP = {"1": "low", "2": "medium", "3": "high", "4": "urgent"}
_PRIORITY_NUMBER_TYPE_MAP: dict[int, str] = {
1: "low",
2: "medium",
3: "high",
4: "urgent",
}

_STATUS_NUMBER_TYPE_MAP = {"2": "open", "3": "pending", "4": "resolved", "5": "closed"}
_STATUS_NUMBER_TYPE_MAP: dict[int, str] = {
2: "open",
3: "pending",
4: "resolved",
5: "closed",
}


def _create_metadata_from_ticket(ticket: dict) -> dict:
Expand Down Expand Up @@ -91,7 +101,7 @@ def _create_metadata_from_ticket(ticket: dict) -> dict:
# Convert source numbers to human-parsable string
if source_number := ticket.get("source"):
metadata["source"] = _SOURCE_NUMBER_TYPE_MAP.get(
str(source_number), "Unknown Source Type"
source_number, "Unknown Source Type"
)

# Convert priority numbers to human-parsable string
Expand All @@ -103,7 +113,7 @@ def _create_metadata_from_ticket(ticket: dict) -> dict:
# Convert status to human-parsable string
if status_number := ticket.get("status"):
metadata["status"] = _STATUS_NUMBER_TYPE_MAP.get(
str(status_number), "Unknown Status"
status_number, "Unknown Status"
)

due_by = datetime.fromisoformat(ticket["due_by"].replace("Z", "+00:00"))
Expand Down

0 comments on commit 70f703c

Please sign in to comment.