mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-26 09:55:52 +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
|
value: profile?.createDateTime
|
||||||
? DateTime.fromJSDate(new Date(profile?.createDateTime))
|
? DateTime.fromJSDate(new Date(profile?.createDateTime))
|
||||||
.toUTC()
|
.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 { SystemProfile } from '../generated/api/data/createTableProfile';
|
||||||
import { Table, TableProfile } from '../generated/entity/data/table';
|
import { Table, TableProfile } from '../generated/entity/data/table';
|
||||||
import { CustomMetric } from '../generated/tests/customMetric';
|
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 { isHasKey } from './ObjectUtils';
|
||||||
import {
|
import {
|
||||||
CalculateColumnProfilerMetricsInterface,
|
CalculateColumnProfilerMetricsInterface,
|
||||||
@ -31,7 +34,10 @@ export const calculateRowCountMetrics = (
|
|||||||
const rowCountMetricData: MetricChartType['data'] = [];
|
const rowCountMetricData: MetricChartType['data'] = [];
|
||||||
|
|
||||||
updateProfilerData.forEach((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({
|
rowCountMetricData.push({
|
||||||
name: timestamp,
|
name: timestamp,
|
||||||
@ -58,7 +64,10 @@ export const calculateSystemMetrics = (
|
|||||||
const operationDateMetrics: MetricChartType['data'] = [];
|
const operationDateMetrics: MetricChartType['data'] = [];
|
||||||
|
|
||||||
updateProfilerData.forEach((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({
|
operationMetrics.push({
|
||||||
name: timestamp,
|
name: timestamp,
|
||||||
@ -94,7 +103,7 @@ export const calculateSystemMetrics = (
|
|||||||
...item,
|
...item,
|
||||||
stackId: stackId,
|
stackId: stackId,
|
||||||
latestValue: operation?.timestamp
|
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']>);
|
}, {} as Record<string, MetricChartType['data']>);
|
||||||
|
|
||||||
updateProfilerData.forEach((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) => {
|
data?.customMetrics?.forEach((metric) => {
|
||||||
if (!isUndefined(metric.name)) {
|
if (!isUndefined(metric.name)) {
|
||||||
const updatedMetric = {
|
const updatedMetric = {
|
||||||
@ -167,7 +179,7 @@ export const calculateColumnProfilerMetrics = ({
|
|||||||
const quartileMetricData: MetricChartType['data'] = [];
|
const quartileMetricData: MetricChartType['data'] = [];
|
||||||
updateProfilerData.forEach((col) => {
|
updateProfilerData.forEach((col) => {
|
||||||
const { timestamp, sum } = 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 };
|
const defaultData = { name, timestamp };
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -15,6 +15,7 @@ import {
|
|||||||
calculateInterval,
|
calculateInterval,
|
||||||
convertMillisecondsToHumanReadableFormat,
|
convertMillisecondsToHumanReadableFormat,
|
||||||
customFormatDateTime,
|
customFormatDateTime,
|
||||||
|
DATE_TIME_12_HOUR_FORMAT,
|
||||||
formatDate,
|
formatDate,
|
||||||
formatDateTime,
|
formatDateTime,
|
||||||
formatDateTimeLong,
|
formatDateTimeLong,
|
||||||
@ -58,6 +59,9 @@ describe('DateTimeUtils tests', () => {
|
|||||||
|
|
||||||
it(`customFormatDateTime should formate date and time both`, () => {
|
it(`customFormatDateTime should formate date and time both`, () => {
|
||||||
expect(customFormatDateTime(0, 'yyyy/MM/dd')).toBe(`1970/01/01`);
|
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 { capitalize, isNil, toInteger, toNumber } from 'lodash';
|
||||||
import { DateTime, Duration } from 'luxon';
|
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
|
* @param date EPOCH millis
|
||||||
* @returns Formatted date for valid input. Format: MMM DD, YYYY, HH:MM AM/PM
|
* @returns Formatted date for valid input. Format: MMM DD, YYYY, HH:MM AM/PM
|
||||||
|
Loading…
x
Reference in New Issue
Block a user