mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-26 01:46:26 +00:00
GEN-1224: fixed Profiler is not displaying correct time for table profile (#18766)
* GEN-1224: fixed Profiler is not displaying correct time for table profile * added unit test
This commit is contained in:
parent
f9a304c386
commit
151c1bbdb3
@ -155,7 +155,7 @@ export const TableProfilerProvider = ({
|
||||
value: profile?.createDateTime
|
||||
? DateTime.fromJSDate(new Date(profile?.createDateTime))
|
||||
.toUTC()
|
||||
.toFormat('MMM dd, yyyy HH:mm')
|
||||
.toLocaleString(DateTime.DATE_MED)
|
||||
: '--',
|
||||
},
|
||||
];
|
||||
|
@ -16,7 +16,10 @@ import { MetricChartType } from '../components/Database/Profiler/ProfilerDashboa
|
||||
import { SystemProfile } from '../generated/api/data/createTableProfile';
|
||||
import { Table, TableProfile } from '../generated/entity/data/table';
|
||||
import { CustomMetric } from '../generated/tests/customMetric';
|
||||
import { customFormatDateTime } from './date-time/DateTimeUtils';
|
||||
import {
|
||||
customFormatDateTime,
|
||||
DATE_TIME_12_HOUR_FORMAT,
|
||||
} from './date-time/DateTimeUtils';
|
||||
import { isHasKey } from './ObjectUtils';
|
||||
import {
|
||||
CalculateColumnProfilerMetricsInterface,
|
||||
@ -31,7 +34,10 @@ export const calculateRowCountMetrics = (
|
||||
const rowCountMetricData: MetricChartType['data'] = [];
|
||||
|
||||
updateProfilerData.forEach((data) => {
|
||||
const timestamp = customFormatDateTime(data.timestamp, 'MMM dd, hh:mm');
|
||||
const timestamp = customFormatDateTime(
|
||||
data.timestamp,
|
||||
DATE_TIME_12_HOUR_FORMAT
|
||||
);
|
||||
|
||||
rowCountMetricData.push({
|
||||
name: timestamp,
|
||||
@ -58,7 +64,10 @@ export const calculateSystemMetrics = (
|
||||
const operationDateMetrics: MetricChartType['data'] = [];
|
||||
|
||||
updateProfilerData.forEach((data) => {
|
||||
const timestamp = customFormatDateTime(data.timestamp, 'MMM dd, hh:mm');
|
||||
const timestamp = customFormatDateTime(
|
||||
data.timestamp,
|
||||
DATE_TIME_12_HOUR_FORMAT
|
||||
);
|
||||
|
||||
operationMetrics.push({
|
||||
name: timestamp,
|
||||
@ -94,7 +103,7 @@ export const calculateSystemMetrics = (
|
||||
...item,
|
||||
stackId: stackId,
|
||||
latestValue: operation?.timestamp
|
||||
? customFormatDateTime(operation?.timestamp, 'MMM dd, hh:mm')
|
||||
? customFormatDateTime(operation?.timestamp, DATE_TIME_12_HOUR_FORMAT)
|
||||
: '--',
|
||||
};
|
||||
});
|
||||
@ -125,7 +134,10 @@ export const calculateCustomMetrics = (
|
||||
}, {} as Record<string, MetricChartType['data']>);
|
||||
|
||||
updateProfilerData.forEach((data) => {
|
||||
const timestamp = customFormatDateTime(data.timestamp, 'MMM dd, hh:mm');
|
||||
const timestamp = customFormatDateTime(
|
||||
data.timestamp,
|
||||
DATE_TIME_12_HOUR_FORMAT
|
||||
);
|
||||
data?.customMetrics?.forEach((metric) => {
|
||||
if (!isUndefined(metric.name)) {
|
||||
const updatedMetric = {
|
||||
@ -167,7 +179,7 @@ export const calculateColumnProfilerMetrics = ({
|
||||
const quartileMetricData: MetricChartType['data'] = [];
|
||||
updateProfilerData.forEach((col) => {
|
||||
const { timestamp, sum } = col;
|
||||
const name = customFormatDateTime(timestamp, 'MMM dd, hh:mm');
|
||||
const name = customFormatDateTime(timestamp, DATE_TIME_12_HOUR_FORMAT);
|
||||
const defaultData = { name, timestamp };
|
||||
|
||||
if (
|
||||
|
@ -15,6 +15,7 @@ import {
|
||||
calculateInterval,
|
||||
convertMillisecondsToHumanReadableFormat,
|
||||
customFormatDateTime,
|
||||
DATE_TIME_12_HOUR_FORMAT,
|
||||
formatDate,
|
||||
formatDateTime,
|
||||
formatDateTimeLong,
|
||||
@ -58,6 +59,9 @@ describe('DateTimeUtils tests', () => {
|
||||
|
||||
it(`customFormatDateTime should formate date and time both`, () => {
|
||||
expect(customFormatDateTime(0, 'yyyy/MM/dd')).toBe(`1970/01/01`);
|
||||
expect(customFormatDateTime(0, DATE_TIME_12_HOUR_FORMAT)).toBe(
|
||||
`Jan 01, 1970, 12:00 AM`
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -13,6 +13,8 @@
|
||||
import { capitalize, isNil, toInteger, toNumber } from 'lodash';
|
||||
import { DateTime, Duration } from 'luxon';
|
||||
|
||||
export const DATE_TIME_12_HOUR_FORMAT = 'MMM dd, yyyy, hh:mm a'; // e.g. Jan 01, 12:00 AM
|
||||
|
||||
/**
|
||||
* @param date EPOCH millis
|
||||
* @returns Formatted date for valid input. Format: MMM DD, YYYY, HH:MM AM/PM
|
||||
|
Loading…
x
Reference in New Issue
Block a user