Skip to content

Commit 260cc68

Browse files
committed
fix stale again
1 parent f6ba5dd commit 260cc68

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

nephthys/tasks/close_stale.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,26 @@ async def get_is_stale(ts: str, max_retries: int = 3) -> bool:
4747
f"Thread not found for ticket {ts}. This might be a deleted thread."
4848
)
4949
await send_heartbeat(f"Thread not found for ticket {ts}.")
50-
await env.db.ticket.update(
51-
where={"msgTs": ts},
52-
data={
53-
"status": TicketStatus.CLOSED,
54-
"closedAt": datetime.now(),
55-
"closedBy": {"connect": {"slackId": env.slack_maintainer_id}},
56-
},
50+
maintainer_user = await env.db.user.find_unique(
51+
where={"slackId": env.slack_maintainer_id}
5752
)
53+
if maintainer_user:
54+
await env.db.ticket.update(
55+
where={"msgTs": ts},
56+
data={
57+
"status": TicketStatus.CLOSED,
58+
"closedAt": datetime.now(),
59+
"closedBy": {"connect": {"id": maintainer_user.id}},
60+
},
61+
)
62+
else:
63+
await env.db.ticket.update(
64+
where={"msgTs": ts},
65+
data={
66+
"status": TicketStatus.CLOSED,
67+
"closedAt": datetime.now(),
68+
},
69+
)
5870
return False
5971
else:
6072
logging.error(

0 commit comments

Comments
 (0)