mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 02:48:13 -05:00
[PR #22167] [MERGED] fix: add missing group_id filter to analytics token usage query #49575
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/22167
Author: @Classic298
Created: 3/2/2026
Status: ✅ Merged
Merged: 3/8/2026
Merged by: @tjbck
Base:
dev← Head:fix/analytics-token-usage-group-filter📝 Commits (1)
6616ff8fix: add missing group_id filter to analytics token usage query📊 Changes
2 files changed (+10 additions, -1 deletions)
View changed files
📝
backend/open_webui/models/chat_messages.py(+9 -0)📝
backend/open_webui/routers/analytics.py(+1 -1)📄 Description
The get_token_usage_by_user query lacked group_id filtering, while the companion get_message_count_by_user query already supported it. When an admin filtered analytics by user group, message counts were correctly scoped to the group but token usage totals included data from all users.
Add the group_id parameter and subquery filter to get_token_usage_by_user, matching the pattern used by get_message_count_by_user and other analytics queries, and pass group_id through from the analytics endpoint.
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.