Skip to content

Commit

Permalink
[Dataset quality] using common data types for timeRange (#177630)
Browse files Browse the repository at this point in the history
This is a [follow
up](#177000 (comment))
PR of #177000.

## Changes
- Replace custom types for `timeRangeConfig` in dataset quality with
common types coming from data plugin.
  • Loading branch information
yngrdyn authored Feb 23, 2024
1 parent d738c2c commit 623177f
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 28 deletions.
4 changes: 2 additions & 2 deletions packages/deeplinks/observability/locators/dataset_quality.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export const DATASET_QUALITY_LOCATOR_ID = 'DATASET_QUALITY_LOCATOR';

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type RefreshInterval = {
isPaused: boolean;
interval: number;
pause: boolean;
value: number;
};

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ export default function Filters() {
onRefreshChange={onRefreshChange}
commonlyUsedRanges={commonlyUsedRanges}
showUpdateButton={true}
isPaused={timeRange.refresh.isPaused}
refreshInterval={timeRange.refresh.interval}
isPaused={timeRange.refresh.pause}
refreshInterval={timeRange.refresh.value}
/>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { TimeRangeConfig } from '../../../state_machines/dataset_quality_control
import { useDatasetQualityContext } from '../../dataset_quality/context';
import { DegradedDocsChart } from './degraded_docs_chart';

const DEFAULT_REFRESH = { interval: 60000, isPaused: false };
const DEFAULT_REFRESH = { value: 60000, pause: false };

export function DegradedDocs({
dataStream,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ export const useDatasetQualityFilters = () => {
timeRange: {
...timeRange,
refresh: {
isPaused,
interval: refreshInterval,
pause: isPaused,
value: refreshInterval,
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export const DEFAULT_CONTEXT: DefaultDatasetQualityControllerState = {
from: 'now-24h',
to: 'now',
refresh: {
isPaused: true,
interval: ONE_MINUTE_IN_MS,
pause: true,
value: ONE_MINUTE_IN_MS,
},
},
integrations: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import { DoneInvokeEvent } from 'xstate';
import { RefreshInterval, TimeRange } from '@kbn/data-plugin/common';
import { Integration } from '../../../../common/data_streams_stats/integration';
import { Direction, SortField } from '../../../hooks';
import { DegradedDocsStat } from '../../../../common/data_streams_stats/malformed_docs_stat';
Expand All @@ -30,14 +31,9 @@ interface TableCriteria {
};
}

export interface TimeRangeConfig {
from: string;
to: string;
refresh: {
isPaused: boolean;
interval: number;
};
}
export type TimeRangeConfig = Pick<TimeRange, 'from' | 'to'> & {
refresh: RefreshInterval;
};

interface FiltersCriteria {
inactive: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ describe('Observability Logs Explorer Locators', () => {

it('should create a link with correct timeRange', async () => {
const refresh = {
isPaused: false,
interval: 0,
pause: false,
value: 0,
};
const locatorParams = {
filters: {
Expand All @@ -410,7 +410,7 @@ describe('Observability Logs Explorer Locators', () => {

expect(location).toMatchObject({
app: OBSERVABILITY_LOGS_EXPLORER_APP_ID,
path: '/dataset-quality?pageState=(filters:(timeRange:(from:now-30m,refresh:(interval:0,isPaused:!f),to:now)),v:1)',
path: '/dataset-quality?pageState=(filters:(timeRange:(from:now-30m,refresh:(pause:!f,value:0),to:now)),v:1)',
state: {},
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ const timeRangeRT = rt.strict({
from: rt.string,
to: rt.string,
refresh: rt.strict({
isPaused: rt.boolean,
interval: rt.number,
pause: rt.boolean,
value: rt.number,
}),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,8 @@ const constructLocatorParams = (
const locatorParams: DatasetQualityLocatorParams = {
filters: {
timeRange: {
from: time?.from || 'now-24h',
to: time?.to || 'now',
refresh: {
isPaused: refreshInterval ? refreshInterval.pause : false,
interval: refreshInterval ? refreshInterval.value : 60000,
},
...(time ?? { from: 'now-24h', to: 'now' }),
refresh: refreshInterval ?? { pause: false, value: 60000 },
},
},
};
Expand Down

0 comments on commit 623177f

Please sign in to comment.