Skip to content

Commit

Permalink
PMM-12425 fix infinite loop for setting timerange (#1544)
Browse files Browse the repository at this point in the history
* PMM-12425 fix infinite loop for setting timerange

* PMM-12425 fix logic to set from time

* PMM-12425 fix linting errors
  • Loading branch information
YashSartanpara1 authored Dec 19, 2023
1 parent 1103699 commit 307b7df
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pmm-app/src/pmm-qan/panel/provider/provider.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useEffect, useRef, useState } from 'react';
import { isEqual, omit } from 'lodash';
import moment from 'moment';
import { parseURL, refreshGrafanaVariables, setLabels } from './provider.tools';
import { QueryAnalyticsContext } from './provider.types';
import { ParseQueryParamDate } from '../../../shared/components/helpers/time-parameters-parser';
Expand Down Expand Up @@ -215,8 +216,13 @@ export const UrlParametersProvider = (props) => {
if (newTo === 'now') {
setToTimeMomentValue(timeRange.to.subtract(1, 'minute')
.format('YYYY-MM-DDTHH:mm:ssZ'));
setFromTimeMomentValue(timeRange.from.subtract(1, 'minute')
.format('YYYY-MM-DDTHH:mm:ssZ'));

if (moment.isMoment(timeRange.raw.from)) {
setFromTimeMomentValue(timeRange.from.format('YYYY-MM-DDTHH:mm:ssZ'));
} else {
setFromTimeMomentValue(timeRange.from.subtract(1, 'minute')
.format('YYYY-MM-DDTHH:mm:ssZ'));
}
} else {
setToTimeMomentValue(timeRange.to.format('YYYY-MM-DDTHH:mm:ssZ'));
setFromTimeMomentValue(timeRange.from.format('YYYY-MM-DDTHH:mm:ssZ'));
Expand Down

0 comments on commit 307b7df

Please sign in to comment.