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

  1. Go to /admin/reports/ai-metering/log.
  2. Set the Model filter to a specific model and apply.
  3. Click "Export JSON".
  4. 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

codeitwisely created an issue. See original summary.

codeitwisely’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.