mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-14 23:22:44 +00:00
fix: align analytics message count with token count by filtering on assistant role
The get_message_count_by_user query was counting messages of ALL roles (user, assistant, system), while get_token_usage_by_user only aggregated tokens from assistant messages with non-null usage data. This mismatch caused the Admin Panel Analytics to show inflated message counts alongside zero tokens for users whose messages were predominantly user-role messages without any token usage data. Align the message count query with the token usage query by adding a role='assistant' filter, so both metrics reflect the same underlying dataset of assistant responses.
This commit is contained in:
parent
f6b85700ea
commit
20949179a9
1 changed files with 4 additions and 1 deletions
|
|
@ -478,7 +478,10 @@ class ChatMessageTable:
|
|||
|
||||
stmt = (
|
||||
select(ChatMessage.user_id, func.count(ChatMessage.id).label('count'))
|
||||
.filter(~ChatMessage.user_id.like('shared-%'))
|
||||
.filter(
|
||||
ChatMessage.role == 'assistant',
|
||||
~ChatMessage.user_id.like('shared-%'),
|
||||
)
|
||||
)
|
||||
|
||||
if start_date:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue