Skip to content

sleep: JSON emits nested seconds while CSV emits flat *_min columns #42

Description

@DTTerastar

Problem

The two codecs for sleep disagree on both units and shape for the same quantities.

  • --format csv computes flat, minute-valued columns: total_sleep_min, light_min, deep_min, rem_min (cmd/sleep.go:167,174-177).
  • --format json passes the upstream blob straight through — Data json.RawMessage (cmd/sleep.go:24) — so the same durations arrive nested and in seconds, and there is no total_sleep_min equivalent at all.

So sleep --format json and sleep --format csv are not two encodings of one dataset; they're two different datasets. A consumer switching codecs has to rewrite its unit handling and its field paths.

Relationship to #27

#27 covers this same JSON/CSV divergence for workouts explicitly. It does not cover sleep. #21 is about float precision in the --derive path, not the flat/nested unit split. So this is unfiled.

If #27 grows into a general "JSON and CSV must carry the same fields in the same units" fix, this can fold into it and be closed — flagging it separately so sleep doesn't get fixed by accident or missed entirely.

Note

This is also an instance of the org-level gap filed as quantcli/common#27 — nothing in the shared contract currently says the same logical field must keep one type and one unit across codecs and subcommands.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions