Problem/Motivation
AiMeteringController mixes dashboard rendering with export logic (CSV, JSON, raw log JSON) in the same class. The export path has its own filtering, row building, filename building, and CSV escaping, none of which the dashboard rendering needs. Keeping both responsibilities in one controller makes the class harder to navigate and test in isolation.
Proposed resolution
Extract the export-related methods (exportCsv(), exportJson(), exportLogJson(), and their private helpers for filtering, row building, filename building, and CSV cell escaping) into a dedicated service, injected into the controller. The controller's export methods become thin wrappers that call the service and return the response. No behavior change.
AI assistance
Yes.
Issue fork ai_metering-3613150
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
codeitwisely commentedComment #6
codeitwisely commented