feat(cli): add export --downsample <seconds> for thinner exports#280
Merged
Conversation
`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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a
--downsample <seconds>flag tothermoworks 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.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
--downsampletakes a positive integer number of seconds and is off by default (every reading is exported, unchanged behavior).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.Testing
pnpm --dir packages/cli typecheck- cleanpnpm --dir packages/cli test- 886 passing (10 new)pnpm lint- cleanNew tests cover
parseExportArgsflag validation (positive integer, missing value, non-integer, zero/negative), thedownsampleRowshelper (bucketing per channel, earliest-in-bucket, unparseable timestamps, empty input), and an end-to-endexportData --downsamplerun.Closes #275