feat: aggregate statistics [ENG-2780, ENG-3139]#7751
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
884b3fc to
fea1609
Compare
| @@ -310,6 +296,20 @@ export const snakeCaseToTitleCase = ( | |||
| ) | |||
| .join(" "); | |||
|
|
|||
| /** | |||
| * Formats a number with a suffix for large numbers (K, M, etc.) | |||
| * @param num - The number to format | |||
| * @param digits - The number of digits to round to (default is 0) | |||
| * @returns The formatted number as a string | |||
| * | |||
| * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat | |||
| * | |||
| * @example | |||
| * nFormatter(1111); // returns "1K" | |||
| * nFormatter(1111, 0); // returns "1K" | |||
| * nFormatter(1111, 1); // returns "1.1K" | |||
| * nFormatter(1111, 2); // returns "1.11K" | |||
| */ | |||
There was a problem hiding this comment.
drive-by fixing of comments
c07ee8e to
92bb486
Compare
64de1e1 to
86dd160
Compare
There was a problem hiding this comment.
Code Review — feat: aggregate statistics [ENG-2780, ENG-3139]
Overall this is a well-structured feature: clean component decomposition, proper feature-flag gating, and the DonutChart enhancements (thin variant, fit prop) are nicely done. A few things to fix before merge:
Suggestions (fix before merge)
- Typo in endpoint/hook names (
getAggretateStatistics→getAggregateStatistics): propagates to both exported hooks and all call sites — worth fixing now before the name spreads further. monitor_typeoptional but used in URL path: the query arg is typedmonitor_type?but interpolated directly into the URL. Either make it required or add a guard.- Duplicated
getMonitorUpdateName: identical function exists in bothMonitorResultDescription.tsxandProgressCard/utils.ts. Extract to a shared location. - Typo in user-facing string:
"accross"→"across"inMONITOR_TYPE_TO_EMPTY_TEXT. - Typo in constant name:
MONITOR_TYPE_TO_PERECENT_STATISTIC_LABEL→MONITOR_TYPE_TO_PERCENT_STATISTIC_LABEL.
Nice to Have
content-centervsitems-centerinDonutChart.tsx:content-centeronly affects multi-line flex containers;items-centeris likely what was intended.PropsWithChildrenwithout children:ProgressCardnever renderschildren, so thePropsWithChildrenwrapper is unnecessary.renderIcondefined inside component: pure function, no closure needed — move it outsideMonitorStats.- Overly complex
classNamesspread pattern:classNames(...["a", ...(cond ? ["b"] : [])])can be simplified toclassNames("a", cond && "b")throughout. heliosInsightstest flag istrue: most alpha flags usetest: false. Confirm existing tests that renderActionCenterLayoutor the website monitor page have been updated to account for the new stats widgets.ExtendedDatastoreMonitorUpdates.tsappears unused: not imported anywhere in the PR — remove if not needed yet.
clients/admin-ui/src/features/data-discovery-and-detection/action-center/action-center.slice.ts
Outdated
Show resolved
Hide resolved
clients/admin-ui/src/features/data-discovery-and-detection/action-center/action-center.slice.ts
Show resolved
Hide resolved
clients/admin-ui/src/features/data-discovery-and-detection/action-center/ProgressCard/utils.ts
Show resolved
Hide resolved
clients/admin-ui/src/features/data-discovery-and-detection/action-center/ProgressCard/utils.ts
Outdated
Show resolved
Hide resolved
clients/admin-ui/src/features/data-discovery-and-detection/action-center/ProgressCard/utils.ts
Outdated
Show resolved
Hide resolved
clients/admin-ui/src/features/data-discovery-and-detection/action-center/MonitorStats.tsx
Outdated
Show resolved
Hide resolved
clients/admin-ui/src/features/data-discovery-and-detection/action-center/MonitorStats.tsx
Show resolved
Hide resolved
clients/admin-ui/src/types/api/models/ExtendedDatastoreMonitorUpdates.ts
Outdated
Show resolved
Hide resolved
Greptile SummaryThis PR adds aggregate statistics widgets to the action center, introducing a new Key issues found:
Confidence Score: 4/5Safe to merge once the hook/endpoint typo and the minor style issues are addressed; the feature is fully gated behind a flag. All issues are cosmetic (typos, naming conventions, one duplicate helper) with no functional impact — the typo in the hook name is consistent across all usage sites so nothing is broken at runtime. The feature flag means no production exposure until explicitly enabled. A quick round of fixes brings this to merge-ready.
Important Files Changed
Reviews (1): Last reviewed commit: "refactor: flag naming" | Re-trigger Greptile |
clients/admin-ui/src/features/data-discovery-and-detection/action-center/action-center.slice.ts
Outdated
Show resolved
Hide resolved
clients/admin-ui/src/features/data-discovery-and-detection/action-center/ProgressCard/utils.ts
Outdated
Show resolved
Hide resolved
clients/admin-ui/src/features/data-discovery-and-detection/action-center/ProgressCard/utils.ts
Outdated
Show resolved
Hide resolved
clients/admin-ui/src/features/data-discovery-and-detection/action-center/ProgressCard/utils.ts
Show resolved
Hide resolved
...min-ui/src/features/data-discovery-and-detection/action-center/ProgressCard/ProgressCard.tsx
Show resolved
Hide resolved
clients/admin-ui/src/features/data-discovery-and-detection/action-center/ProgressCard/utils.ts
Show resolved
Hide resolved
| const { width, height } = useContainerSize(containerRef); | ||
| const size = Math.min(width, height); | ||
| const size = | ||
| fit === "contain" ? Math.min(width, height) : Math.max(width, height); |
| <div | ||
| className={classNames( | ||
| "w-full", | ||
| !monitorId && "grid grid-cols-3 gap-4 pb-4", | ||
| )} | ||
| > |
There was a problem hiding this comment.
Would it be worth using Ant Col/Row for this?
There was a problem hiding this comment.
Hmmm I'll give it a look.
Ant Col/Row is disappointing imo since it uses flex + requires lots of component boilerplate.
Performance aside, css grids are way more powerful and predictable for layouts.
| className={classNames( | ||
| `grid overflow-hidden w-full gap-2 xl:gap-4`, | ||
| compact | ||
| ? "grid-cols-[1fr,min-content,1fr,min-content,1fr]" | ||
| : "grid-cols-1 xl:grid-cols-[auto,1fr,1fr]", |
There was a problem hiding this comment.
Same comment as before - should we use Row/Col for this? Your approach is neater, just wanted to call out as an option.
| switch (true) { | ||
| case percent > 80: | ||
| return "colorSuccess"; | ||
| case percent > 60: | ||
| return "colorWarning"; | ||
| default: | ||
| return "colorErrorTextHover"; |
There was a problem hiding this comment.
Future consideration: I think we should standardize thresholds for colors.
There was a problem hiding this comment.
Absolutely.
We should have rules that also apply outside of numeric thresholds as well.
This was just an initial pass for now.
kruulik
left a comment
There was a problem hiding this comment.
Approving - my comments are minor and don't need to be addressed in this PR, just future considerations.
chore: more types chore: even more types chore: all the types wip: something that works chore: adding query hook chore: wip chore: more types chore: more type updates wip: more card stuff chore: update types wip: some labels and such chore: fix comments core: layout improvements and refactoring chore: linting and formatting chore: more responsiveness chore: further refactors wip: stuf chore: comment out refactor: compact variant chore: mostly there fix: formatting fix: donut chart fit feature fix: formatting chore: adding changelog
chore: update text fix: linting and formatting
396d22b to
31ad093
Compare
Ticket [ENG-2780, ENG-3139]
Description Of Changes
Adding a progress indicator widget to the action center
Code Changes
Steps to Confirm
Pre-Merge Checklist
CHANGELOG.mdupdatedmaindowngrade()migration is correct and works