Problem/Motivation
The "Export JSON" link on /admin/reports/ai-metering/log calls a
custom controller that queries ai_metering_usage directly and
ignores any exposed filters (Provider, Model, Period). The downloaded file
always contains the full unfiltered dataset.
The exports on /admin/reports/ai-metering and
/admin/reports/ai-metering/by-role are out of scope.
Steps to reproduce
- Go to
/admin/reports/ai-metering/log. - Set the Model filter to a specific model and apply.
- Click "Export JSON".
- Observe: the downloaded file contains all models.
Environment
- ai_metering 1.0.0-alpha1
Proposed resolution
Add a views_data_export
JSON display to the ai_metering_usage_log View, using the same
module introduced by the CSV fix (#3605378).
No additional dependency. The display inherits all exposed filters and handles
large logs via batch processing.
The alternative is the core Views REST export display — no contrib needed, but
no batch processing. On a log with thousands of rows that path is prone to
timeouts.
Remaining tasks
- Add a VDE JSON display to
ai_metering_usage_log.view.yml
(depends on CSV issue). - Remove or redirect the legacy JSON controller route.
- Add a test asserting the export respects the active Model filter.
- Review.
User interface changes
The "Export JSON" link triggers a views_data_export batch instead of an
immediate download. UX is otherwise unchanged.
API changes
None.
Data model changes
None.
AI assistance
N/A
Comments
Comment #2
codeitwisely commented