From b9b47c0978417d6ac249c573f2fff10dfa8c05e4 Mon Sep 17 00:00:00 2001 From: shahramk Date: Mon, 25 Mar 2024 18:08:53 -0700 Subject: [PATCH] refactor: remove local timeRangeToNrql function and use the labs-components version --- lib/timeRangeToNrql.js | 21 ------------------- .../service-containers/service-containers.js | 2 +- nerdlets/shared/container-charts.js | 2 +- 3 files changed, 2 insertions(+), 23 deletions(-) delete mode 100644 lib/timeRangeToNrql.js diff --git a/lib/timeRangeToNrql.js b/lib/timeRangeToNrql.js deleted file mode 100644 index fb73648..0000000 --- a/lib/timeRangeToNrql.js +++ /dev/null @@ -1,21 +0,0 @@ -const MINUTE = 60000; -const HOUR = 60 * MINUTE; -const DAY = 24 * HOUR; - -export const timeRangeToNrql = function ({ timeRange = false }) { - if (!timeRange) { - return 'SINCE 30 minutes ago'; - } - - if (timeRange.beginTime && timeRange.endTime) { - return `SINCE ${timeRange.beginTime} UNTIL ${timeRange.endTime}`; - } else if (timeRange.begin_time && timeRange.end_time) { - return `SINCE ${timeRange.begin_time} UNTIL ${timeRange.end_time}`; - } else if (timeRange.duration <= HOUR) { - return `SINCE ${timeRange.duration / MINUTE} MINUTES AGO`; - } else if (timeRange.duration <= DAY) { - return `SINCE ${timeRange.duration / HOUR} HOURS AGO`; - } else { - return `SINCE ${timeRange.duration / DAY} DAYS AGO`; - } -}; diff --git a/nerdlets/service-containers/service-containers.js b/nerdlets/service-containers/service-containers.js index f33e06b..d5fef82 100644 --- a/nerdlets/service-containers/service-containers.js +++ b/nerdlets/service-containers/service-containers.js @@ -11,7 +11,7 @@ import { } from 'nr1'; import nrdbQuery from '../../lib/nrdb-query'; -import { timeRangeToNrql } from '../../lib/timeRangeToNrql'; +import { timeRangeToNrql } from '@newrelic/nr-labs-components'; import findRelatedAccountsWith from '../../lib/find-related-account-with'; import accountsWithData from '../../lib/accounts-with-data'; diff --git a/nerdlets/shared/container-charts.js b/nerdlets/shared/container-charts.js index 6f4e0e2..e705559 100644 --- a/nerdlets/shared/container-charts.js +++ b/nerdlets/shared/container-charts.js @@ -1,7 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { PlatformStateContext, LineChart, NrqlQuery, ChartGroup } from 'nr1'; -import { timeRangeToNrql } from '../../lib/timeRangeToNrql'; +import { timeRangeToNrql } from '@newrelic/nr-labs-components'; // roll up all of the facet data into a single summarized series. function summarizeFacets(data) {