Skip to content

Conversation

@ShaileshParmar11
Copy link
Contributor

@ShaileshParmar11 ShaileshParmar11 commented Dec 18, 2025

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:

  • Added a new utility function convertSecondsToHumanReadableFormat in DateTimeUtils.ts to 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 new Date.constants.ts file. [1] [2] [3]
  • Updated all usages in TestSummaryGraph.tsx and TestSummaryCustomTooltip.component.tsx to use convertSecondsToHumanReadableFormat instead of the previous convertMillisecondsToHumanReadableFormat, ensuring correct and consistent formatting of freshness values received from the backend. [1] [2] [3] [4]

Testing and mock updates:

  • Modified Jest mocks in related test files to use the new convertSecondsToHumanReadableFormat function, 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.

Copy link
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

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 convertSecondsToHumanReadableFormat utility 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

@github-actions
Copy link
Contributor

github-actions bot commented Dec 18, 2025

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 64%
64.3% (50881/79129) 41.9% (24774/59130) 45.39% (7806/17199)

…Profiler/TestSummaryCustomTooltip/TestSummaryCustomTooltip.test.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
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

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`),
Copy link

Copilot AI Dec 18, 2025

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.

Suggested change
.mockImplementation((val) => `${val}ms`),
.mockImplementation((val) => `${val}s`),

Copilot uses AI. Check for mistakes.
@sonarqubecloud
Copy link

@ShaileshParmar11 ShaileshParmar11 enabled auto-merge (squash) December 19, 2025 06:42
@ShaileshParmar11 ShaileshParmar11 merged commit 9731654 into main Dec 19, 2025
23 checks passed
@ShaileshParmar11 ShaileshParmar11 deleted the freshness-bug branch December 19, 2025 06:47
@github-project-automation github-project-automation bot moved this from In Review / QA 👀 to Done ✅ in Jan - 2026 Dec 19, 2025
@github-actions
Copy link
Contributor

Changes have been cherry-picked to the 1.11.4 branch.

github-actions bot pushed a commit that referenced this pull request Dec 19, 2025
* 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs To release Will cherry-pick this PR into the release branch UI UI specific issues

Projects

Status: Done ✅

Development

Successfully merging this pull request may close these issues.

3 participants