= ({ data }) => {
) : (
-
- {isGraphLoading ? (
-
- ) : results.length ? (
-
-
-
- axisTickFormatter(value)}
- />
-
-
- {data.parameterValues?.length === 2 && referenceArea()}
- {chartData?.information?.map((info, i) => (
-
- ))}
-
-
- ) : (
-
-
- {t('message.try-different-time-period-filtering')}
-
-
- )}
+ {getGraph()}
)}
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/ProfilerDashboard/profilerDashboard.interface.ts b/openmetadata-ui/src/main/resources/ui/src/components/ProfilerDashboard/profilerDashboard.interface.ts
index c804eaa6c87..911d628821e 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/ProfilerDashboard/profilerDashboard.interface.ts
+++ b/openmetadata-ui/src/main/resources/ui/src/components/ProfilerDashboard/profilerDashboard.interface.ts
@@ -19,6 +19,7 @@ import {
Table,
} from '../../generated/entity/data/table';
import { TestCase } from '../../generated/tests/testCase';
+import { DateRangeObject } from './component/TestSummary';
export interface ProfilerDashboardProps {
onTableChange: (table: Table) => void;
@@ -26,7 +27,10 @@ export interface ProfilerDashboardProps {
table: Table;
testCases: TestCase[];
profilerData: ColumnProfile[];
- fetchProfilerData: (tableId: string, days?: number) => void;
+ fetchProfilerData: (
+ tableId: string,
+ dateRangeObject?: DateRangeObject
+ ) => void;
fetchTestCases: (fqn: string, params?: ListTestCaseParams) => void;
onTestCaseUpdate: (deleted?: boolean) => void;
}
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/Component/TableProfilerChart.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/Component/TableProfilerChart.test.tsx
index ee73de2bab6..3f2ea806c6c 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/Component/TableProfilerChart.test.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/Component/TableProfilerChart.test.tsx
@@ -14,37 +14,20 @@
import { act, render, screen } from '@testing-library/react';
import React from 'react';
import { getSystemProfileList, getTableProfilesList } from 'rest/tableAPI';
-import {
- getPastDatesTimeStampFromCurrentDate,
- getPastDaysDateTimeMillis,
-} from '../../../utils/TimeUtils';
import TableProfilerChart from './TableProfilerChart';
const mockFQN = 'testFQN';
const mockTimeValue = {
endSec: 1670667984,
startSec: 1670408784,
- endMilli: 1670667985445,
- startMilli: 1670408785445,
+ endMilli: 1670667984000,
+ startMilli: 1670408784000,
};
+const mockDateRangeObject = { startTs: 1670408784, endTs: 1670667984 };
jest.mock('react-router-dom', () => ({
useParams: jest.fn().mockImplementation(() => ({ datasetFQN: mockFQN })),
}));
-jest.mock('../../../utils/TimeUtils', () => ({
- getCurrentDateTimeMillis: jest
- .fn()
- .mockImplementation(() => mockTimeValue.endMilli),
- getCurrentDateTimeStamp: jest
- .fn()
- .mockImplementation(() => mockTimeValue.endSec),
- getPastDatesTimeStampFromCurrentDate: jest
- .fn()
- .mockImplementation(() => mockTimeValue.startSec),
- getPastDaysDateTimeMillis: jest
- .fn()
- .mockImplementation(() => mockTimeValue.startMilli),
-}));
jest.mock('rest/tableAPI');
jest.mock('../../ProfilerDashboard/component/ProfilerLatestValue', () => {
return jest.fn().mockImplementation(() => ProfilerLatestValue
);
@@ -64,7 +47,7 @@ describe('TableProfilerChart component test', () => {
const mockGetSystemProfileList = getSystemProfileList as jest.Mock;
const mockGetTableProfilesList = getTableProfilesList as jest.Mock;
act(() => {
- render();
+ render();
});
expect(
@@ -89,7 +72,7 @@ describe('TableProfilerChart component test', () => {
const mockGetSystemProfileList = getSystemProfileList as jest.Mock;
const mockGetTableProfilesList = getTableProfilesList as jest.Mock;
await act(async () => {
- render();
+ render();
});
// API should be call once
@@ -111,20 +94,14 @@ describe('TableProfilerChart component test', () => {
it('If TimeRange change API should be call accordingly', async () => {
const startTime = {
- inMilli: 1670063664901,
- inSec: 1670063664,
+ inMilli: 1670408784000,
+ inSec: 1670408784,
};
const mockGetSystemProfileList = getSystemProfileList as jest.Mock;
const mockGetTableProfilesList = getTableProfilesList as jest.Mock;
- (getPastDatesTimeStampFromCurrentDate as jest.Mock).mockImplementationOnce(
- () => startTime.inSec
- );
- (getPastDaysDateTimeMillis as jest.Mock).mockImplementationOnce(
- () => startTime.inMilli
- );
await act(async () => {
- render();
+ render();
});
// API should be call with proper Param value
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/Component/TableProfilerChart.tsx b/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/Component/TableProfilerChart.tsx
index 64285cb4c80..f2456c643ae 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/Component/TableProfilerChart.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/Component/TableProfilerChart.tsx
@@ -13,24 +13,18 @@
import { Card, Col, Row } from 'antd';
import { AxiosError } from 'axios';
+import { DateRangeObject } from 'components/ProfilerDashboard/component/TestSummary';
import React, { useEffect, useState } from 'react';
import { useParams } from 'react-router-dom';
import { getSystemProfileList, getTableProfilesList } from 'rest/tableAPI';
import {
INITIAL_OPERATION_METRIC_VALUE,
INITIAL_ROW_METRIC_VALUE,
- PROFILER_FILTER_RANGE,
} from '../../../constants/profiler.constant';
import {
calculateRowCountMetrics,
calculateSystemMetrics,
} from '../../../utils/TableProfilerUtils';
-import {
- getCurrentDateTimeMillis,
- getCurrentDateTimeStamp,
- getPastDatesTimeStampFromCurrentDate,
- getPastDaysDateTimeMillis,
-} from '../../../utils/TimeUtils';
import { showErrorToast } from '../../../utils/ToastUtils';
import CustomBarChart from '../../Chart/CustomBarChart';
import OperationDateBarChart from '../../Chart/OperationDateBarChart';
@@ -40,7 +34,7 @@ import ProfilerLatestValue from '../../ProfilerDashboard/component/ProfilerLates
import { MetricChartType } from '../../ProfilerDashboard/profilerDashboard.interface';
import { TableProfilerChartProps } from '../TableProfiler.interface';
-const TableProfilerChart = ({ selectedTimeRange }: TableProfilerChartProps) => {
+const TableProfilerChart = ({ dateRangeObject }: TableProfilerChartProps) => {
const { datasetFQN } = useParams<{ datasetFQN: string }>();
const [rowCountMetrics, setRowCountMetrics] = useState(
@@ -53,28 +47,24 @@ const TableProfilerChart = ({ selectedTimeRange }: TableProfilerChartProps) => {
useState(INITIAL_OPERATION_METRIC_VALUE);
const [isLoading, setIsLoading] = useState(true);
- const fetchTableProfiler = async (fqn: string, days = 3) => {
+ const fetchTableProfiler = async (
+ fqn: string,
+ dateRangeObj: DateRangeObject
+ ) => {
try {
- const startTs = getPastDatesTimeStampFromCurrentDate(days);
- const endTs = getCurrentDateTimeStamp();
- const { data } = await getTableProfilesList(fqn, {
- startTs,
- endTs,
- });
+ const { data } = await getTableProfilesList(fqn, dateRangeObj);
const rowMetricsData = calculateRowCountMetrics(data, rowCountMetrics);
setRowCountMetrics(rowMetricsData);
} catch (error) {
showErrorToast(error as AxiosError);
}
};
- const fetchSystemProfiler = async (fqn: string, days = 3) => {
+ const fetchSystemProfiler = async (
+ fqn: string,
+ dateRangeObj: DateRangeObject
+ ) => {
try {
- const startTs = getPastDaysDateTimeMillis(days);
- const endTs = getCurrentDateTimeMillis();
- const { data } = await getSystemProfileList(fqn, {
- startTs,
- endTs,
- });
+ const { data } = await getSystemProfileList(fqn, dateRangeObj);
const { operationMetrics: metricsData, operationDateMetrics } =
calculateSystemMetrics(data, operationMetrics);
@@ -85,23 +75,26 @@ const TableProfilerChart = ({ selectedTimeRange }: TableProfilerChartProps) => {
}
};
- const fetchProfilerData = async (fqn: string, days = 3) => {
+ const fetchProfilerData = async (
+ fqn: string,
+ dateRangeObj: DateRangeObject
+ ) => {
setIsLoading(true);
- await fetchTableProfiler(fqn, days);
- await fetchSystemProfiler(fqn, days);
+ await fetchTableProfiler(fqn, dateRangeObj);
+ await fetchSystemProfiler(fqn, {
+ startTs: dateRangeObj.startTs * 1000,
+ endTs: dateRangeObj.endTs * 1000,
+ });
setIsLoading(false);
};
useEffect(() => {
if (datasetFQN) {
- fetchProfilerData(
- datasetFQN,
- PROFILER_FILTER_RANGE[selectedTimeRange].days
- );
+ fetchProfilerData(datasetFQN, dateRangeObject);
} else {
setIsLoading(false);
}
- }, [datasetFQN, selectedTimeRange]);
+ }, [datasetFQN, dateRangeObject]);
if (isLoading) {
return ;
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/TableProfiler.interface.ts b/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/TableProfiler.interface.ts
index 6dfd0064f64..3286bbeb21d 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/TableProfiler.interface.ts
+++ b/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/TableProfiler.interface.ts
@@ -11,7 +11,7 @@
* limitations under the License.
*/
-import { PROFILER_FILTER_RANGE } from '../../constants/profiler.constant';
+import { DateRangeObject } from 'components/ProfilerDashboard/component/TestSummary';
import { SystemProfile } from '../../generated/api/data/createTableProfile';
import {
Column,
@@ -82,7 +82,7 @@ export type TableProfilerData = {
};
export type TableProfilerChartProps = {
- selectedTimeRange: keyof typeof PROFILER_FILTER_RANGE;
+ dateRangeObject: DateRangeObject;
};
export interface ProfilerSettingModalState {
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/TableProfilerV1.tsx b/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/TableProfilerV1.tsx
index 5dd834c5f9e..6df8f687d56 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/TableProfilerV1.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/TableProfilerV1.tsx
@@ -28,7 +28,9 @@ import { DefaultOptionType } from 'antd/lib/select';
import { SwitchChangeEventHandler } from 'antd/lib/switch';
import { AxiosError } from 'axios';
import classNames from 'classnames';
-import { isUndefined, map } from 'lodash';
+import DatePickerMenu from 'components/DatePickerMenu/DatePickerMenu.component';
+import { DateRangeObject } from 'components/ProfilerDashboard/component/TestSummary';
+import { isEqual, isUndefined, map } from 'lodash';
import React, { FC, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Link, useParams } from 'react-router-dom';
@@ -42,8 +44,8 @@ import { ReactComponent as TableProfileIcon } from '../../assets/svg/table-profi
import { API_RES_MAX_SIZE } from '../../constants/constants';
import { PAGE_HEADERS } from '../../constants/PageHeaders.constant';
import {
+ DEFAULT_RANGE_DATA,
INITIAL_TEST_RESULT_SUMMARY,
- PROFILER_FILTER_RANGE,
} from '../../constants/profiler.constant';
import { ProfilerDashboardType } from '../../enums/table.enum';
import { ProfileSampleType, Table } from '../../generated/entity/data/table';
@@ -95,8 +97,8 @@ const TableProfilerV1: FC = ({
const [selectedTestType, setSelectedTestType] = useState('');
const [deleted, setDeleted] = useState(false);
const [isTestCaseLoading, setIsTestCaseLoading] = useState(false);
- const [selectedTimeRange, setSelectedTimeRange] =
- useState('last3days');
+ const [dateRangeObject, setDateRangeObject] =
+ useState(DEFAULT_RANGE_DATA);
const isSummary = activeTab === ProfilerDashboardTab.SUMMARY;
const isDataQuality = activeTab === ProfilerDashboardTab.DATA_QUALITY;
const isProfiler = activeTab === ProfilerDashboardTab.PROFILER;
@@ -229,20 +231,13 @@ const TableProfilerV1: FC = ({
},
];
- const timeRangeOption = useMemo(() => {
- return Object.entries(PROFILER_FILTER_RANGE).map(([key, value]) => ({
- label: value.title,
- value: key,
- }));
- }, []);
-
const handleTabChange: MenuProps['onClick'] = (value) => {
setActiveTab(value.key as ProfilerDashboardTab);
};
- const handleTimeRangeChange = (value: keyof typeof PROFILER_FILTER_RANGE) => {
- if (value !== selectedTimeRange) {
- setSelectedTimeRange(value);
+ const handleDateRangeChange = (value: DateRangeObject) => {
+ if (!isEqual(value, dateRangeObject)) {
+ setDateRangeObject(value);
}
};
@@ -400,11 +395,9 @@ const TableProfilerV1: FC = ({
)}
{isProfiler && (
-
)}
@@ -515,7 +508,7 @@ const TableProfilerV1: FC = ({
)}
{isProfiler && (
-
+
)}
{settingModalVisible && (
diff --git a/openmetadata-ui/src/main/resources/ui/src/constants/DataInsight.constants.ts b/openmetadata-ui/src/main/resources/ui/src/constants/DataInsight.constants.ts
index 3a00b425ca6..6344dd3ba7b 100644
--- a/openmetadata-ui/src/main/resources/ui/src/constants/DataInsight.constants.ts
+++ b/openmetadata-ui/src/main/resources/ui/src/constants/DataInsight.constants.ts
@@ -52,7 +52,7 @@ export const DATA_INSIGHT_GRAPH_COLORS = [
];
export const BAR_SIZE = 15;
-export const DEFAULT_DAYS = 30;
+export const DEFAULT_DAYS = 1;
export const ENTITIES_BAR_COLO_MAP: Record = {
Chart: '#E7B85D',
diff --git a/openmetadata-ui/src/main/resources/ui/src/constants/profiler.constant.ts b/openmetadata-ui/src/main/resources/ui/src/constants/profiler.constant.ts
index c77a9d27c0c..a2fa8f48e72 100644
--- a/openmetadata-ui/src/main/resources/ui/src/constants/profiler.constant.ts
+++ b/openmetadata-ui/src/main/resources/ui/src/constants/profiler.constant.ts
@@ -14,6 +14,10 @@
import { t } from 'i18next';
import { StepperStepType } from 'Models';
import i18n from 'utils/i18next/LocalUtil';
+import {
+ getCurrentDateTimeStamp,
+ getPastDatesTimeStampFromCurrentDate,
+} from 'utils/TimeUtils';
import { CSMode } from '../enums/codemirror.enum';
import { DMLOperationType } from '../generated/api/data/createTableProfile';
import {
@@ -67,6 +71,10 @@ export const PROFILER_METRIC = [
];
export const PROFILER_FILTER_RANGE = {
+ yesterday: {
+ days: 1,
+ title: t('label.yesterday'),
+ },
last3days: {
days: 3,
title: t('label.last-number-of-days', {
@@ -99,6 +107,18 @@ export const PROFILER_FILTER_RANGE = {
},
};
+export const DEFAULT_SELECTED_RANGE = {
+ key: 'yesterday',
+ title: t('label.yesterday'),
+ days: 1,
+};
+
+export const DEFAULT_RANGE_DATA = {
+ startTs: getPastDatesTimeStampFromCurrentDate(DEFAULT_SELECTED_RANGE.days),
+
+ endTs: getCurrentDateTimeStamp(),
+};
+
export const COLORS = ['#7147E8', '#B02AAC', '#B02AAC', '#1890FF', '#008376'];
export const DEFAULT_CHART_COLLECTION_VALUE = {
diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json
index 25d7374e96f..84998f4d406 100644
--- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json
+++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json
@@ -153,6 +153,7 @@
"custom-oidc": "CustomOidc",
"custom-property": "Custom property",
"custom-property-plural": "Custom Properties",
+ "custom-range": "Custom Range",
"dag": "Dag",
"dag-view": "DAG view",
"daily-active-users-on-the-platform": "Daily Active Users on the Platform",
@@ -910,6 +911,7 @@
"weekly-usage": "Weekly Usage",
"whats-new": "What's New",
"yes": "Yes",
+ "yesterday": "Yesterday",
"your-entity": "Your {{entity}}"
},
"message": {
diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/es-es.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/es-es.json
index faeec2060a7..aaaa6be9db4 100644
--- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/es-es.json
+++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/es-es.json
@@ -153,6 +153,7 @@
"custom-oidc": "OIDC personalizado",
"custom-property": "Propiedad personalizada",
"custom-property-plural": "Propiedades personalizadas",
+ "custom-range": "Custom Range",
"dag": "DAG",
"dag-view": "Vista DAG",
"daily-active-users-on-the-platform": "Usuarios activos diarios en la plataforma",
@@ -910,6 +911,7 @@
"weekly-usage": "Uso semanal",
"whats-new": "Novedades",
"yes": "Sí",
+ "yesterday": "Yesterday",
"your-entity": "Tu {{entity}}"
},
"message": {
diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/fr-fr.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/fr-fr.json
index 66cabddb7a5..c3b6119084e 100644
--- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/fr-fr.json
+++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/fr-fr.json
@@ -153,6 +153,7 @@
"custom-oidc": "CustomOidc",
"custom-property": "Custom property",
"custom-property-plural": "Propriétés Personalisées",
+ "custom-range": "Custom Range",
"dag": "Dag",
"dag-view": "Vue DAG",
"daily-active-users-on-the-platform": "Utilisateurs actifs quotidiens",
@@ -910,6 +911,7 @@
"weekly-usage": "Weekly Usage",
"whats-new": "Nouveau",
"yes": "Yes",
+ "yesterday": "Yesterday",
"your-entity": "Your {{entity}}"
},
"message": {
diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/ja-jp.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/ja-jp.json
index 42d8b14f09f..603dda878e1 100644
--- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/ja-jp.json
+++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/ja-jp.json
@@ -153,6 +153,7 @@
"custom-oidc": "CustomOidc",
"custom-property": "カスタムプロパティ",
"custom-property-plural": "カスタムプロパティ",
+ "custom-range": "Custom Range",
"dag": "Dag",
"dag-view": "DAGビュー",
"daily-active-users-on-the-platform": "このプラットフォームのアクティブなユーザー",
@@ -910,6 +911,7 @@
"weekly-usage": "Weekly Usage",
"whats-new": "最新情報",
"yes": "はい",
+ "yesterday": "Yesterday",
"your-entity": "あなたの{{entity}}"
},
"message": {
diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/pt-br.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/pt-br.json
index 0c4f93c8cd2..e1bae073602 100644
--- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/pt-br.json
+++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/pt-br.json
@@ -153,6 +153,7 @@
"custom-oidc": "OIDC customizado",
"custom-property": "Propriedade customizada",
"custom-property-plural": "Propriedades customizadas",
+ "custom-range": "Custom Range",
"dag": "DAG",
"dag-view": "Visão da DAG",
"daily-active-users-on-the-platform": "Usuários ativos diariamente na plataforma",
@@ -910,6 +911,7 @@
"weekly-usage": "Uso semanal",
"whats-new": "O que há de novo",
"yes": "Sim",
+ "yesterday": "Yesterday",
"your-entity": "Sua {{entity}}"
},
"message": {
diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/zh-cn.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/zh-cn.json
index 95cf9a96d8b..8063bcbbcdc 100644
--- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/zh-cn.json
+++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/zh-cn.json
@@ -153,6 +153,7 @@
"custom-oidc": "CustomOidc",
"custom-property": "Custom property",
"custom-property-plural": "定制属性",
+ "custom-range": "Custom Range",
"dag": "Dag",
"dag-view": "DAG view",
"daily-active-users-on-the-platform": "Daily active users on the platform",
@@ -910,6 +911,7 @@
"weekly-usage": "Weekly Usage",
"whats-new": "What's new",
"yes": "是",
+ "yesterday": "Yesterday",
"your-entity": "Your {{entity}}"
},
"message": {
diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/DataInsightPage/DataInsightPage.component.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/DataInsightPage/DataInsightPage.component.tsx
index 864e9b4da0a..621b09e5673 100644
--- a/openmetadata-ui/src/main/resources/ui/src/pages/DataInsightPage/DataInsightPage.component.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/pages/DataInsightPage/DataInsightPage.component.tsx
@@ -11,16 +11,7 @@
* limitations under the License.
*/
-import {
- Button,
- Card,
- Col,
- Row,
- Select,
- Space,
- Tooltip,
- Typography,
-} from 'antd';
+import { Button, Card, Col, Row, Space, Tooltip, Typography } from 'antd';
import PageContainerV1 from 'components/containers/PageContainerV1';
import PageLayoutV1 from 'components/containers/PageLayoutV1';
import DailyActiveUsersChart from 'components/DataInsightDetail/DailyActiveUsersChart';
@@ -33,11 +24,14 @@ import TierInsight from 'components/DataInsightDetail/TierInsight';
import TopActiveUsers from 'components/DataInsightDetail/TopActiveUsers';
import TopViewEntities from 'components/DataInsightDetail/TopViewEntities';
import TotalEntityInsight from 'components/DataInsightDetail/TotalEntityInsight';
+import DatePickerMenu from 'components/DatePickerMenu/DatePickerMenu.component';
+import { DateRangeObject } from 'components/ProfilerDashboard/component/TestSummary';
import SearchDropdown from 'components/SearchDropdown/SearchDropdown';
import { SearchDropdownOption } from 'components/SearchDropdown/SearchDropdown.interface';
+import { DEFAULT_RANGE_DATA } from 'constants/profiler.constant';
import { EntityFields } from 'enums/AdvancedSearch.enum';
import { t } from 'i18next';
-import { isEmpty } from 'lodash';
+import { isEmpty, isEqual } from 'lodash';
import React, { useEffect, useLayoutEffect, useMemo, useState } from 'react';
import { ListItem } from 'react-awesome-query-builder';
import { useHistory, useParams } from 'react-router-dom';
@@ -46,7 +40,6 @@ import { searchQuery } from 'rest/searchAPI';
import { autocomplete } from '../../constants/AdvancedSearch.constants';
import { PAGE_SIZE, ROUTES } from '../../constants/constants';
import {
- DAY_FILTER,
DEFAULT_DAYS,
ENTITIES_CHARTS,
INITIAL_CHART_FILTER,
@@ -64,11 +57,7 @@ import {
getDataInsightPathWithFqn,
getTeamFilter,
} from '../../utils/DataInsightUtils';
-import {
- getCurrentDateTimeMillis,
- getFormattedDateFromMilliSeconds,
- getPastDaysDateTimeMillis,
-} from '../../utils/TimeUtils';
+import { getFormattedDateFromMilliSeconds } from '../../utils/TimeUtils';
import { TeamStateType, TierStateType } from './DataInsight.interface';
import './DataInsight.less';
import DataInsightLeftPanel from './DataInsightLeftPanel';
@@ -101,6 +90,8 @@ const DataInsightPage = () => {
useState(INITIAL_CHART_FILTER);
const [kpiList, setKpiList] = useState>([]);
const [selectedDaysFilter, setSelectedDaysFilter] = useState(DEFAULT_DAYS);
+ const [dateRangeObject, setDateRangeObject] =
+ useState(DEFAULT_RANGE_DATA);
const [selectedChart, setSelectedChart] = useState();
@@ -133,13 +124,20 @@ const DataInsightPage = () => {
}));
};
- const handleDaysChange = (days: number) => {
- setSelectedDaysFilter(days);
- setChartFilter((previous) => ({
- ...previous,
- startTs: getPastDaysDateTimeMillis(days),
- endTs: getCurrentDateTimeMillis(),
- }));
+ const handleDateRangeChange = (
+ value: DateRangeObject,
+ daysValue?: number
+ ) => {
+ if (!isEqual(value, dateRangeObject)) {
+ setDateRangeObject(value);
+ setSelectedDaysFilter(daysValue ?? 0);
+ setChartFilter((previous) => ({
+ ...previous,
+ // Converting coming data to milliseconds
+ startTs: value.startTs * 1000,
+ endTs: value.endTs * 1000,
+ }));
+ }
};
const handleTeamChange = (teams: SearchDropdownOption[] = []) => {
@@ -341,11 +339,9 @@ const DataInsightPage = () => {
'dd MMM yyyy'
)}`}
-
diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/ProfilerDashboardPage/ProfilerDashboardPage.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/ProfilerDashboardPage/ProfilerDashboardPage.tsx
index 871357e0d33..cc2015c2790 100644
--- a/openmetadata-ui/src/main/resources/ui/src/pages/ProfilerDashboardPage/ProfilerDashboardPage.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/pages/ProfilerDashboardPage/ProfilerDashboardPage.tsx
@@ -20,8 +20,10 @@ import {
OperationPermission,
ResourceEntity,
} from 'components/PermissionProvider/PermissionProvider.interface';
+import { DateRangeObject } from 'components/ProfilerDashboard/component/TestSummary';
import ProfilerDashboard from 'components/ProfilerDashboard/ProfilerDashboard';
import { ProfilerDashboardTab } from 'components/ProfilerDashboard/profilerDashboard.interface';
+import { DEFAULT_RANGE_DATA } from 'constants/profiler.constant';
import { compare } from 'fast-json-patch';
import { isEmpty } from 'lodash';
import React, { useEffect, useState } from 'react';
@@ -46,10 +48,6 @@ import {
import { DEFAULT_ENTITY_PERMISSION } from '../../utils/PermissionsUtils';
import { getDecodedFqn } from '../../utils/StringsUtils';
import { generateEntityLink } from '../../utils/TableUtils';
-import {
- getCurrentDateTimeStamp,
- getPastDatesTimeStampFromCurrentDate,
-} from '../../utils/TimeUtils';
import { showErrorToast } from '../../utils/ToastUtils';
const ProfilerDashboardPage = () => {
@@ -89,16 +87,15 @@ const ProfilerDashboardPage = () => {
}
};
- const fetchProfilerData = async (fqn: string, days = 3) => {
+ const fetchProfilerData = async (
+ fqn: string,
+ dateRangeObject?: DateRangeObject
+ ) => {
try {
- const startTs = getPastDatesTimeStampFromCurrentDate(days);
-
- const endTs = getCurrentDateTimeStamp();
-
- const { data } = await getColumnProfilerList(fqn, {
- startTs,
- endTs,
- });
+ const { data } = await getColumnProfilerList(
+ fqn,
+ dateRangeObject ?? DEFAULT_RANGE_DATA
+ );
setProfilerData(data);
} catch (error) {
showErrorToast(error as AxiosError);
diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/DatePickerMenuUtils.tsx b/openmetadata-ui/src/main/resources/ui/src/utils/DatePickerMenuUtils.tsx
new file mode 100644
index 00000000000..d1858291b2d
--- /dev/null
+++ b/openmetadata-ui/src/main/resources/ui/src/utils/DatePickerMenuUtils.tsx
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2023 Collate.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { t } from 'i18next';
+
+export const getTimestampLabel = (
+ startDate: string,
+ endDate: string,
+ showSelectedCustomRange?: boolean
+) => {
+ let label = t('label.custom-range');
+ if (showSelectedCustomRange) {
+ label += `: ${startDate} -> ${endDate}`;
+ }
+
+ return label;
+};
+
+export const getDaysCount = (startDate: string, endDate: string) => {
+ const startDateObj = new Date(startDate);
+ const endDateObj = new Date(endDate);
+ const timeDifference = endDateObj.getTime() - startDateObj.getTime();
+
+ // Dividing time difference with number of milliseconds in a day to get number of days
+ const numOfDays = timeDifference / (1000 * 60 * 60 * 24);
+
+ return numOfDays;
+};