feat: use same duration functions #3156
Open
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.
Closes #3133
Greptile Overview
Greptile Summary
This PR consolidates duration formatting by renaming functions to be more semantically accurate and consistent across the codebase.
Key Changes:
formatUptimeInSecondstoformatDurationSecondsandformatMsToUptimetoformatDurationMsfor clearer naming that better reflects their generic duration formatting purposeformatUptime.test.tstoformatDuration.test.tswith updated test cases@gravity-ui/date-utilsdirectly, now uses sharedformatDurationMsfunctionImpact:
The refactor improves code maintainability by consolidating duration formatting into consistently-named utility functions, eliminating duplication and ensuring uniform formatting across the application.
Confidence Score: 5/5
Important Files Changed
File Analysis
formatUptimeInSecondstoformatDurationSecondsandformatMsToUptimetoformatDurationMsfor clearer function namingformatUptime.test.tstoformatDuration.test.tsand updated test cases to use new function names@gravity-ui/date-utilswithformatDurationMs, removed unused imports and constantsSequence Diagram
sequenceDiagram participant Components as UI Components participant Formatters as Duration Formatters participant GravityUI as @gravity-ui/date-utils Note over Components,GravityUI: Duration Formatting Refactor Components->>Formatters: formatDurationMs(ms) Formatters->>Formatters: Convert ms to seconds Formatters->>Formatters: formatDurationSeconds(seconds) alt seconds is NaN Formatters-->>Components: undefined else valid duration Formatters->>GravityUI: duration(Math.abs(seconds), 's').rescale() GravityUI-->>Formatters: duration object alt days > 0 Formatters->>Formatters: format as "Xd HH:MM:SS" else hours > 0 Formatters->>Formatters: format as "H:MM:SS" else minutes > 0 Formatters->>Formatters: format as "M:SS" else seconds only Formatters->>Formatters: format as "Xs" end Formatters->>Formatters: Add sign if negative Formatters-->>Components: formatted string end Note over Components: VDiskInfo, VDiskPopup Note over Components: Operations columns Note over Components: Consumers/Partitions diagnosticsCI Results
Test Status:⚠️ FLAKY
📊 Full Report
Test Changes Summary ⏭️2
⏭️ Skipped Tests (2)
Bundle Size: ✅
Current: 62.33 MB | Main: 62.33 MB
Diff: 0.28 KB (-0.00%)
✅ Bundle size unchanged.
ℹ️ CI Information