Skip to content
This repository has been archived by the owner on Dec 13, 2024. It is now read-only.

Commit

Permalink
Add comments to tickets
Browse files Browse the repository at this point in the history
At the moment tickets are backed up with no comment thread. This means we end up with the initial problem, but not the resolution. The aim of this addition is to include the comments.
  • Loading branch information
jonodrew committed May 2, 2024
1 parent 2a74700 commit b533997
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lambda_/zendesk_backup/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,18 @@ def save_support(ticket_ids: Optional[list] = None):
tickets = zenpy_client().search_export(type="ticket")

for ticket in tickets:
comment_thread = zenpy_client().tickets.comments(ticket)
# subject = re.sub(r"\s+", " ", re.sub(r"[^a-zA-Z0-9 ]", "", ticket.raw_subject))
filename = f"gc3-{ticket.id}.json"
key = f"{s3_support_prefix}tickets/{filename}"
jprint(f"Saving 's3://{s3_bucket}/{key}'")

dobj = add_athena_datetimes(ticket.to_dict())
ticket_as_dict = ticket.to_dict()

dobj = add_athena_datetimes(ticket_as_dict)

# add all comments to the ticket
ticket_as_dict["comments"] = [comment.to_dict() for comment in comment_thread]

s3_client().put_object(
Body=json.dumps(dobj, default=str).encode("utf-8"),
Expand Down

0 comments on commit b533997

Please sign in to comment.