Problem/Motivation
On the "AI Usage by Role" dashboard (/admin/reports/ai-metering/by-role), the sum of calls across individual role rows does not match the ALL ROLES total. For example:
- Administrator: 73 calls (59 cloud / 14 local)
- Content validator: 4 calls (4 cloud / 0 local)
- Speaker: 6 calls (6 cloud / 0 local)
- ALL ROLES: 77 calls (63 cloud / 14 local)
This is expected: a user with multiple roles is counted in each applicable row, so per-role rows can overlap. The ALL ROLES row counts each user once. The current template includes a note explaining this, but it appears below the table, after the reader has already noticed the apparent discrepancy and may have started investigating a data bug that does not exist.
Steps to reproduce
- Install ai_metering with at least one user who belongs to two or more roles.
- Record some AI usage for that user.
- Navigate to
/admin/reports/ai-metering/by-role. - Compare the per-role totals with the ALL ROLES row and notice the numbers do not add up.
- Scroll past the table to find the note that explains why.
Environment
- Drupal version: 10.x / 11.x
- ai_metering version: 1.0.x-dev
- AI provider module + version (e.g. ai_provider_anthropic 1.x): any
- AI feature module tested (e.g. ai_translate, ai_chatbot, ai_assistant_api, ai_summarize...): any
Proposed resolution
Move the explanatory note above the table, immediately below the "Role breakdown" heading, so it is visible before the data. Simplify the wording to:
Users with multiple roles appear in each applicable row. ALL ROLES counts each user once.
Remove the duplicate note that currently sits below the table.
Remaining tasks
- Move the note above the table in
templates/ai-metering-by-role.html.twig. - Remove the duplicate note from below the table.
User interface changes
The explanatory note moves from below the table to above it. No functional or data model change.
API changes
N/A
Data model changes
N/A
AI assistance
Issue summary drafted with assistance from Claude. Approved by @codeitwisely.
Comments
Comment #3
codeitwisely commented