Skip to content

Improve --latest option (legacy)#49

Open
pjcdawkins wants to merge 2 commits intomainfrom
migrate/legacy-pr-1596
Open

Improve --latest option (legacy)#49
pjcdawkins wants to merge 2 commits intomainfrom
migrate/legacy-pr-1596

Conversation

@pjcdawkins
Copy link
Copy Markdown
Contributor

@pjcdawkins pjcdawkins commented Apr 27, 2026

Migrated from platformsh/legacy-cli#1596 (original author: @mharacewiat).

Adds a LATEST_GRAIN constant (300s) used as the default range and interval when --latest is given without an explicit --interval, and updates the option help to mention the 5-minute aggregation window. The 5.x DI/public const style was preserved when re-applying the patch.

Closes #45

Copilot AI review requested due to automatic review settings April 27, 2026 19:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the legacy metrics commands’ --latest behavior to use a 5-minute “grain” by default (and a 5-minute range when no explicit range/interval is provided), aligning the CLI output with the metrics API’s aggregation window expectations.

Changes:

  • Added LATEST_GRAIN (300s) and documented DEFAULT_RANGE as 10 minutes.
  • Updated --latest option help text to mention the 5-minute aggregation window and how to override it.
  • Adjusted time validation so --latest defaults to a 5-minute range and grain when --interval is not provided.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread legacy/src/Command/Metrics/MetricsCommandBase.php
Detect whether `--interval` was provided using a strict null/empty-string
check rather than truthiness, so a literal `0` (or any duration that
parses to zero seconds) is rejected with a clear error instead of being
silently replaced with the default range/grain.

Also corrects a stale "Invalid --range" message in the --interval
validation branch.

Addresses Copilot review feedback on #49.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Metrics behavior is a bit strange compared to a few months ago.

3 participants