Skip to content

Add CSV output to dispatch stats #279

Description

@jongio

Problem

dispatch stats prints a readable summary and --json for scripts, but there is no format that drops straight into a spreadsheet or a plotting tool. The per-repo, per-branch, and per-host breakdowns and the --calendar day counts are exactly the kind of tabular data people want to chart, and JSON makes that an extra parsing step for a quick pivot table.

flowchart TD
    A[dispatch stats --csv] --> B[Build stats report]
    B --> C[Emit section,label,count rows]
    A2[dispatch stats --csv --calendar] --> D[Add date,count,intensity rows]
    C --> E[CSV to stdout]
    D --> E
Loading

Proposed solution

Add a --csv output format to dispatch stats:

  • Emit the repository, branch, and host-type breakdowns as CSV rows with a section,label,count shape, using encoding/csv so labels with commas or quotes are escaped correctly.
  • Include a totals row (sessions, turns, files) so the summary numbers are present too.
  • When combined with --calendar, append the per-day series as date,count,intensity rows under a calendar section.
  • Reject combining --csv with --json, since they are two output formats.

Honor the existing --repo, --branch, --folder, --since, and --until filters exactly as the text and JSON paths do.

Acceptance criteria

  • dispatch stats --csv writes the totals and the repo/branch/host breakdowns as valid CSV.
  • dispatch stats --csv --calendar appends the per-day counts and intensity.
  • The filter flags narrow the CSV the same way they narrow text and JSON output.
  • Labels containing commas or quotes are escaped per RFC 4180 (via encoding/csv).
  • Passing both --csv and --json is rejected with a clear error.
  • Help text documents --csv; unit tests cover the breakdowns, the calendar rows, and the conflicting-flag case.

Notes

buildStatsReport and buildActivityCalendar already produce the structured data; this change only adds a renderer next to writeStatsJSON/writeStatsText.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestideaFeature idea from the idea pipeline

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions