Skip to content

feat(cli): add export --downsample <seconds> for thinner exports#280

Merged
jongio merged 1 commit into
mainfrom
idea/cli-export-downsample
Jul 13, 2026
Merged

feat(cli): add export --downsample <seconds> for thinner exports#280
jongio merged 1 commit into
mainfrom
idea/cli-export-downsample

Conversation

@jongio

@jongio jongio commented Jul 12, 2026

Copy link
Copy Markdown
Owner

What

Adds a --downsample <seconds> flag to thermoworks export. It keeps at most one reading per channel per fixed time bucket, so a long cook logged every few seconds can be exported as a per-minute or per-five-minute series.

thermoworks export ABC123 --downsample 60 --format csv --output brisket.csv
thermoworks export ABC123 --downsample 300 --format json

Why

Archive exports include every logged reading, which for a multi-hour cook can be thousands of rows per channel. That is a lot to chart or store when a coarser series would do. Downsampling thins the output without needing a second tool.

How

  • --downsample takes a positive integer number of seconds and is off by default (every reading is exported, unchanged behavior).
  • A pure downsampleRows(rows, intervalSeconds) helper keeps the earliest reading in each channel's time bucket. Buckets are aligned to the Unix epoch, so the same instants bucket the same way across channels and repeated exports.
  • Rows with an unparseable timestamp are always kept, so no data is silently dropped.
  • Downsampling runs on the flattened rows before formatting, so it applies to csv, json, and influx output alike.

Testing

  • pnpm --dir packages/cli typecheck - clean
  • pnpm --dir packages/cli test - 886 passing (10 new)
  • pnpm lint - clean

New tests cover parseExportArgs flag validation (positive integer, missing value, non-integer, zero/negative), the downsampleRows helper (bucketing per channel, earliest-in-bucket, unparseable timestamps, empty input), and an end-to-end exportData --downsample run.

Closes #275

`export --downsample <seconds>` keeps at most one reading per channel
per fixed time bucket, so a long cook logged every few seconds can be
exported as a per-minute or per-five-minute series. Buckets are aligned
to the Unix epoch, so the same instants bucket the same way across
channels and repeated exports; the earliest reading in each bucket is
kept. Rows with an unparseable timestamp are always kept.

The flag takes a positive integer number of seconds and is off by
default (every reading is exported). Downsampling runs on the flattened
rows before formatting, so it applies to csv, json, and influx output
alike.

Closes #275

Co-authored-by: Copilot App <[email protected]>
@jongio jongio added cli CLI package enhancement New feature or request idea Feature idea from the idea pipeline labels Jul 12, 2026
@jongio jongio self-assigned this Jul 12, 2026
@jongio jongio merged commit 564aed6 into main Jul 13, 2026
2 checks passed
@jongio jongio deleted the idea/cli-export-downsample branch July 13, 2026 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI package enhancement New feature or request idea Feature idea from the idea pipeline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI: Add export --downsample to thin large exports

1 participant