diff --git a/x-pack/legacy/plugins/uptime/server/lib/adapters/monitor_states/search/query_context.ts b/x-pack/legacy/plugins/uptime/server/lib/adapters/monitor_states/search/query_context.ts index 32f46291f2f85..edb86120db927 100644 --- a/x-pack/legacy/plugins/uptime/server/lib/adapters/monitor_states/search/query_context.ts +++ b/x-pack/legacy/plugins/uptime/server/lib/adapters/monitor_states/search/query_context.ts @@ -96,8 +96,8 @@ export class QueryContext { // only slower, but only marginally so, and prevents people from seeing weird // behavior. - const tsStart = parseRelativeEndDate(this.dateRangeEnd)!.subtract(5, 'minutes'); const tsEnd = parseRelativeEndDate(this.dateRangeEnd)!; + const tsStart = tsEnd.subtract(5, 'minutes'); return { range: { diff --git a/x-pack/legacy/plugins/uptime/server/lib/helper/get_histogram_interval.ts b/x-pack/legacy/plugins/uptime/server/lib/helper/get_histogram_interval.ts index fd33310653cb6..625a9fab71bb2 100644 --- a/x-pack/legacy/plugins/uptime/server/lib/helper/get_histogram_interval.ts +++ b/x-pack/legacy/plugins/uptime/server/lib/helper/get_histogram_interval.ts @@ -7,12 +7,12 @@ import DateMath from '@elastic/datemath'; import { QUERY } from '../../../common/constants'; -export const parseRelativeEndDate = (_dateEnd: string) => { +export const parseRelativeEndDate = (dateEndStr: string) => { // We need this this parsing because if user selects This week or this date // That represents end date in future, if week or day is still in the middle // Uptime data can never be collected in future, so we will reset end date to now // in That case. Example case we select this week range will be to='now/w' and from = 'now/w'; - const dateEnd = DateMath.parse(_dateEnd, { roundUp: true }); + const dateEnd = DateMath.parse(dateEndStr, { roundUp: true }); const dateEndTimestamp = dateEnd?.valueOf() ?? 0; if (dateEndTimestamp > Date.now()) { return DateMath.parse('now');