feat: 无标题智能纪要链接用最近会议名称兜底
This commit is contained in:
@ -251,6 +251,7 @@ def fetch_calendar_events(
|
||||
event_map = response.get("events") or {}
|
||||
events = []
|
||||
used_urls: set[str] = set()
|
||||
event_end_times: list[tuple[int, str]] = []
|
||||
for instance in response.get("calendarEventInstance") or []:
|
||||
event = event_map.get(str(instance.get("eventRefId") or ""), {})
|
||||
locations = event.get("locations") or []
|
||||
@ -280,9 +281,23 @@ def fetch_calendar_events(
|
||||
"url": ai_notes_url or native_url or manual_url,
|
||||
}
|
||||
)
|
||||
event_end_times.append((event_end_ts, summary))
|
||||
events.sort(key=lambda event: (event["begin"], event["summary"]))
|
||||
# Collect unmatched links for separate display
|
||||
unmatched_links = [
|
||||
link for link in ai_notes_links if link["url"] not in used_urls
|
||||
]
|
||||
# Fall back to the nearest meeting name for untitled links (e.g. docx notices).
|
||||
for link in unmatched_links:
|
||||
if link.get("topic"):
|
||||
continue
|
||||
best_delta = None
|
||||
best_summary = ""
|
||||
for end_ts, summary in event_end_times:
|
||||
delta = link["create_time"] - end_ts
|
||||
if abs(delta) <= 21600 and (best_delta is None or abs(delta) < abs(best_delta)):
|
||||
best_delta = delta
|
||||
best_summary = summary
|
||||
if best_summary:
|
||||
link["topic"] = best_summary
|
||||
return events, unmatched_links
|
||||
|
||||
Reference in New Issue
Block a user