mirror of
https://github.com/open-webui/open-webui.git
synced 2026-08-30 17:25:30 -05:00
[PR #22165] [CLOSED] fix: align analytics message count with token count by filtering on assistant role #113836
Reference in New Issue
Block a user
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/22165
Author: @Classic298
Created: 3/2/2026
Status: ❌ Closed
Base:
dev← Head:fix/analytics-message-count-role-filter📝 Commits (2)
2094917fix: align analytics message count with token count by filtering on assistant role51d7cc8Merge branch 'dev' into fix/analytics-message-count-role-filter📊 Changes
1 file changed (+6 additions, -2 deletions)
View changed files
📝
backend/open_webui/models/chat_messages.py(+6 -2)📄 Description
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.
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.