feat(metrics): add client-side list filters (FT-1966)#42
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThis PR adds client-side filtering to Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
src/core/metrics/list.tsESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. src/core/metrics/metrics.test.tsESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/core/metrics/list.ts`:
- Around line 66-87: The loop in listAllMetrics stops at FETCH_ALL_MAX_PAGES and
always returns pagination.hasMore: false, which can silently truncate results;
fix by tracking whether we hit the page cap or whether the last fetched page was
full and use that to set hasMore. Concretely, inside listAllMetrics (the for
loop that calls client.listMetrics) capture the length of the last fetched page
into a variable (e.g., lastFetchedLength), and set a boolean hitCap when page
=== FETCH_ALL_MAX_PAGES and lastFetchedLength === pageSize; after the loop
return pagination.hasMore = hitCap || lastFetchedLength === pageSize so callers
see there may be more pages when the cap was reached or the final page was full.
Ensure you reference client.listMetrics, FETCH_ALL_MAX_PAGES, pageSize and
listAllMetrics when making the change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 955c3d04-9248-4801-b2a5-412e81c793ac
📒 Files selected for processing (10)
README.mdsrc/commands/metrics/index.tssrc/commands/metrics/metrics.test.tssrc/core/metrics/filter.test.tssrc/core/metrics/filter.tssrc/core/metrics/list.tssrc/core/metrics/metrics.test.tssrc/lib/utils/list-command.test.tssrc/lib/utils/list-command.tssrc/lib/utils/pagination.ts
Summary
abs metrics listcan return hundreds of metrics with no way to narrow them. This adds client-side filtering flags so users can filter by metric type, goal, outlier-limiting, goal property filter, impact direction, and CUPED.When any of these filters is active, the CLI fetches all pages, filters locally, and prints a
N results (filtered).footer instead of the page-based one. When none are active, behavior is unchanged (single page). All filtering is client-side — server-side equivalents are a documented follow-up.New flags:
--metric-type <values>— by type (comma-separated, OR)--goal <values>— by goal name or ID; matches numerator and denominator goals--outlier-limiting/--no-outlier-limitingand--outlier-method <values>--has-property-filter/--no-property-filter,--property-filter-path <values>,--property-filter-contains <text>--impact-direction <values>(positive/negative/unknown)--cuped/--no-cupedFilters combine with AND across flags, OR within a comma-separated list.
Architecture:
src/core/metrics/filter.ts— pure parse/validate/filter modulesrc/core/metrics/list.ts—listAllMetricspages through every metric (resolving owners/teams once)src/lib/utils/list-command.ts+pagination.ts— optionalisClientFilteredhook +printFilteredFootersrc/commands/metrics/index.ts— wiringJIRA: FT-1966
Test Plan
listAllMetricspagination tests (multi-page, single-page, resolve-once)--has/--no-property-filterconflictlatamprofile: filtering narrows 200+ metrics to filtered subsets with the(filtered)footer;-o jsonemits filtered JSONSummary by CodeRabbit
New Features
Documentation
Tests