mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-07 02:58:21 +00:00
fix: Daily Messages chart in Analytics fails to load on All time when a message has no timestamp (#31888)
With All time selected, the Daily Messages chart in Admin Panel > Analytics failed to load (the daily analytics request returned a 500) as soon as one message had been saved without a timestamp, for example a chat created through the API with a null timestamp. A date range still worked because those messages were left out of it. Such messages now get the time they were saved, and ones already stored without a timestamp are counted on today's date instead of breaking the chart. Messages that came after the missing timestamp in the same chat were also left out of analytics before and are now counted. Fixes #27316
This commit is contained in:
parent
c5dac0070d
commit
f25708484b
1 changed files with 4 additions and 2 deletions
|
|
@ -31,9 +31,11 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
|||
####################
|
||||
|
||||
|
||||
def _normalize_timestamp(timestamp: int) -> float:
|
||||
def _normalize_timestamp(timestamp: Optional[int]) -> float:
|
||||
"""Normalize and validate timestamp. Returns current time if invalid."""
|
||||
now = time.time()
|
||||
if timestamp is None:
|
||||
return now
|
||||
|
||||
# Convert milliseconds to seconds if needed
|
||||
if timestamp > 10_000_000_000:
|
||||
|
|
@ -263,7 +265,7 @@ class ChatMessageTable:
|
|||
error=data.get('error'),
|
||||
usage=get_usage(data),
|
||||
context_summary=data.get('context_summary') or data.get('contextSummary'),
|
||||
created_at=data.get('timestamp', now),
|
||||
created_at=data.get('timestamp') or now,
|
||||
updated_at=now,
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue