Skip to content

Commit f8ff9d9

Browse files
committed
fix: timestamp display
1 parent f52c4c1 commit f8ff9d9

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

helpdesk/api/otto/summary.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def get_summaries(ticket: str) -> list[Summary]:
148148

149149
for session, use in tool_uses:
150150
summarized_by = owner_map.get(session, "Unknown")
151-
summary = _get_summary_from_tool_use(use, summarized_by)
151+
summary = _get_summary_from_tool_use(use, summarized_by, session)
152152
summaries.append(summary)
153153
return summaries
154154

@@ -192,8 +192,8 @@ def _summarize(ticket_id: str):
192192
},
193193
)
194194

195-
# Mark tool uses as completed, session won't be called after this Mainly
196-
# used for timestamps
195+
# Mark tool uses as completed, session won't be called after this.
196+
# Mainly to show up as completed in the reports.
197197
updates: list[otto.types.ToolUseUpdate] = []
198198
for use in session.get_pending_tool_use():
199199
now = time.time()
@@ -212,7 +212,11 @@ def _summarize(ticket_id: str):
212212
# Publish summary to the frontend
213213
uses = session.get_tool_uses(name="summarize_ticket")
214214
if len(uses):
215-
summary = _get_summary_from_tool_use(uses[0], frappe.session.user or "Unknown")
215+
summary = _get_summary_from_tool_use(
216+
uses[0],
217+
frappe.session.user or "Unknown",
218+
session.id,
219+
)
216220
frappe.publish_realtime(
217221
event=summary_event,
218222
user=frappe.session.user,
@@ -226,12 +230,16 @@ def _summarize(ticket_id: str):
226230
return res, session
227231

228232

229-
def _get_summary_from_tool_use(use: "ToolUseContent", summarized_by: str):
233+
def _get_summary_from_tool_use(use: "ToolUseContent", summarized_by: str, session: str):
230234
from otto.lib.utils import to_html
231235

232236
use["end_time"]
233237
args = use["args"]
234238

239+
creation = frappe.get_value("Otto Session", session, "modified")
240+
if isinstance(creation, datetime.datetime):
241+
creation = creation.isoformat()
242+
235243
user = frappe.get_value(
236244
"User",
237245
summarized_by,
@@ -241,7 +249,7 @@ def _get_summary_from_tool_use(use: "ToolUseContent", summarized_by: str):
241249
summarizer = user.get("full_name", user.get("first_name", ""))
242250

243251
return Summary(
244-
creation=datetime.datetime.fromtimestamp(use["end_time"]).isoformat(),
252+
creation=creation,
245253
summarizer=summarizer,
246254
summarized_by=summarized_by,
247255
snippet=to_html(args.get("snippet", "")),
@@ -309,7 +317,7 @@ def _get_context_from_communications(ticket_id: str):
309317
context.append(
310318
f"<ticket_communication date='{date}' sender_name='{name}' sender_email='{sender}' subject='{subject}' >"
311319
)
312-
context.extend(otto.utils.interpolate_imgs(content))
320+
context.extend(otto.utils.interpolate_imgs(content, skip_errors=True))
313321
context.append("</ticket_communication>")
314322

315323
return context

0 commit comments

Comments
 (0)