Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import type { CategorizationAdditionalFilter } from '@kbn/aiops-log-pattern-anal
import type { EmbeddablePatternAnalysisInput } from '@kbn/aiops-log-pattern-analysis/embeddable';
import { useTableState } from '@kbn/ml-in-memory-table/hooks/use_table_state';
import { AIOPS_ANALYSIS_RUN_ORIGIN, AIOPS_EMBEDDABLE_ORIGIN } from '@kbn/aiops-common/constants';
import datemath from '@elastic/datemath';
import useMountedState from 'react-use/lib/useMountedState';
import { getEsQueryConfig } from '@kbn/data-service';
import { calculateBounds } from '@kbn/data-plugin/common';
import { useFilterQueryUpdates } from '../../../hooks/use_filters_query';
import type { PatternAnalysisProps } from '../../../shared_components/pattern_analysis';
import { useSearch } from '../../../hooks/use_search';
Expand Down Expand Up @@ -135,10 +135,9 @@ export const LogCategorizationEmbeddable: FC<LogCategorizationEmbeddableProps> =

const timeRangeParsed = useMemo(() => {
if (timeRange) {
const min = datemath.parse(timeRange.from);
const max = datemath.parse(timeRange.to);
if (min && max) {
return { min, max };
const bounds = calculateBounds(timeRange);
if (bounds.min && bounds.max) {
return { min: bounds.min, max: bounds.max };
}
}
}, [timeRange]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@

import React, { useMemo, type FC } from 'react';

import datemath from '@elastic/datemath';

import type { TimeRange } from '@kbn/es-query';
import { buildEsQuery } from '@kbn/es-query';
import { getEsQueryConfig } from '@kbn/data-service';

import { calculateBounds } from '@kbn/data-plugin/common';
import { useAiopsAppContext } from '../../hooks/use_aiops_app_context';
import { useFilterQueryUpdates } from '../../hooks/use_filters_query';
import { useSearch } from '../../hooks/use_search';
Expand Down Expand Up @@ -45,10 +44,9 @@ export const LogRateAnalysisForEmbeddable: FC<LogRateAnalysisForEmbeddableProps>

const timeRangeParsed = useMemo(() => {
if (timeRange) {
const min = datemath.parse(timeRange.from);
const max = datemath.parse(timeRange.to);
if (min && max) {
return { min, max };
const bounds = calculateBounds(timeRange);
if (bounds.min && bounds.max) {
return { min: bounds.min, max: bounds.max };
}
}
}, [timeRange]);
Expand Down
Loading