Skip to content

Commit

Permalink
refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 committed Jan 31, 2020
1 parent 6f45458 commit 1d03d75
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 1d03d75

Please sign in to comment.