-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix: time conversion issue for table freshness test #24900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a critical bug in the time conversion logic for table freshness test displays. The backend provides freshness values in seconds, but the frontend was incorrectly treating them as milliseconds and converting them with value * 1000, causing the displayed values to be off by a factor of 1000. The fix introduces a new utility function convertSecondsToHumanReadableFormat that properly handles second-based inputs using fixed time unit constants (360-day year, 30-day month) to match backend calculations.
Key changes:
- New
convertSecondsToHumanReadableFormatutility function with fixed time units matching backend freshness calculations - Updated all freshness-related components to use the new function without the millisecond conversion
- Comprehensive test coverage including production bug scenarios, monotonic ordering validation, and edge cases
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
DateTimeUtils.ts |
Added new convertSecondsToHumanReadableFormat function with proper seconds-to-human-readable conversion logic using fixed time units |
Date.constants.ts |
New file defining time unit constants (YEAR_SECONDS=31104000, MONTH_SECONDS=2592000, etc.) used by the conversion function |
DateTimeUtils.test.ts |
Added comprehensive test suite for new function covering basic cases, negative values, combined units, length truncation, edge cases, production scenarios, and monotonic ordering |
TestSummaryCustomTooltip.component.tsx |
Updated to use convertSecondsToHumanReadableFormat instead of convertMillisecondsToHumanReadableFormat, removed incorrect * 1000 multiplication |
TestSummaryGraph.tsx |
Updated Y-axis formatter to use convertSecondsToHumanReadableFormat, removed incorrect * 1000 multiplication |
TestSummaryCustomTooltip.test.tsx |
Updated mock to use new function name and changed test assertions from .toEqual() to .toBe() for primitive values |
TestSummaryGraph.test.tsx |
Updated mock to use new convertSecondsToHumanReadableFormat function name |
.../src/components/Database/Profiler/TestSummaryCustomTooltip/TestSummaryCustomTooltip.test.tsx
Outdated
Show resolved
Hide resolved
…Profiler/TestSummaryCustomTooltip/TestSummaryCustomTooltip.test.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
| convertMillisecondsToHumanReadableFormat: jest | ||
| convertSecondsToHumanReadableFormat: jest | ||
| .fn() | ||
| .mockImplementation((val) => `${val}ms`), |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mock implementation returns a string with 'ms' suffix, which is misleading since this function converts seconds (not milliseconds) to human-readable format. Consider using a more accurate suffix like 's' or 'sec' to make the mock clearer and avoid confusion.
| .mockImplementation((val) => `${val}ms`), | |
| .mockImplementation((val) => `${val}s`), |
|
|
Changes have been cherry-picked to the 1.11.4 branch. |
* fix: time conversion issue for table freshness test * Update openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/TestSummaryCustomTooltip/TestSummaryCustomTooltip.test.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> (cherry picked from commit 9731654)



Issue: Incorrect data displayed in tooltip for freshness test
Screen.Recording.2025-12-18.at.6.36.13.PM.mov
Solution:
Screen.Recording.2025-12-18.at.7.49.29.PM.mov
This pull request standardizes how time durations are displayed in the UI for data freshness and related metrics by introducing a new utility function for converting seconds into a human-readable format, and updating all related usages and tests accordingly. This ensures consistency with the backend, which provides freshness values in seconds, and improves the clarity of time-based information shown to users.
Time formatting improvements:
convertSecondsToHumanReadableFormatinDateTimeUtils.tsto convert seconds into a compact, human-readable string using fixed units (years, months, days, hours, minutes, seconds), matching backend conventions. Supporting constants were added in a newDate.constants.tsfile. [1] [2] [3]TestSummaryGraph.tsxandTestSummaryCustomTooltip.component.tsxto useconvertSecondsToHumanReadableFormatinstead of the previousconvertMillisecondsToHumanReadableFormat, ensuring correct and consistent formatting of freshness values received from the backend. [1] [2] [3] [4]Testing and mock updates:
convertSecondsToHumanReadableFormatfunction, and updated test assertions for consistency with the new output. [1] [2] [3]These changes collectively improve the accuracy and consistency of time duration displays in the UI, particularly for data freshness metrics.