Problem/Motivation

The "Export CSV" link on /admin/reports/ai-metering/log calls a
custom controller route that queries ai_metering_usage directly.
It ignores any exposed filters the user has set (Provider, Model, Period).
Filtering to a specific provider then exporting gives the full unfiltered dataset.

The exports on /admin/reports/ai-metering and
/admin/reports/ai-metering/by-role are out of scope — those
pages have no pagination yet and their export behavior is unchanged.

Steps to reproduce

  1. Go to /admin/reports/ai-metering/log.
  2. Set the Provider filter to anthropic and apply.
  3. Click "Export CSV".
  4. Observe: the downloaded file contains rows from all providers.

Environment

  • ai_metering 1.0.0-alpha1

Proposed resolution

Replace the custom CSV controller with a
views_data_export
display added to the ai_metering_usage_log View. The display
inherits all exposed filters, so the export reflects exactly what the user sees.
Batch processing handles large logs without timeouts.

Remaining tasks

  • Add drupal/views_data_export to composer.json.
  • Add a VDE CSV display to ai_metering_usage_log.view.yml.
  • Remove or redirect the legacy CSV controller route.
  • Add a test asserting the export respects the active Provider filter.
  • Review.

User interface changes

The "Export CSV" 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.

  • 15ae13a5 committed on 1.0.x-3605378-csv-json-log-exports
    Issue #3605378 by codeitwisely: Move export links from Views config to...

  • 34a7545f committed on 1.0.x-3605378-csv-json-log-exports
    Issue #3605378 by codeitwisely: Remove area_text_custom header plugin...

  • d68fbede committed on 1.0.x-3605378-csv-json-log-exports
    Issue #3605378 by codeitwisely: CSV export honours active Views filters...

  • d123bb86 committed on 1.0.x-3605378-csv-json-log-exports
    Issue #3605378 by codeitwisely: CSV export honours active Views filters...

  • ca0f732f committed on 1.0.x-3605378-csv-json-log-exports
    Issue #3605378 by codeitwisely: CSV export honours active Views filters...

  • codeitwisely committed 7099d430 on 1.0.x
    Issue #3605378 #3605379: CSV and JSON exports honour active Views...
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.