This is an automated email from the ASF dual-hosted git repository.

akshayrai09 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 32cb705  Make timezone configurable on frontend (#5374)
32cb705 is described below

commit 32cb705bbad1debed68363773238448fc87f2e85
Author: Tamas Nemeth <[email protected]>
AuthorDate: Thu May 14 02:10:57 2020 +0200

    Make timezone configurable on frontend (#5374)
---
 thirdeye/thirdeye-frontend/app/pods/application/route.js           | 2 +-
 .../app/pods/components/alert-details/component.js                 | 5 +++--
 .../app/pods/components/anomaly-summary/component.js               | 7 +++++++
 .../app/pods/components/anomaly-summary/template.hbs               | 2 +-
 .../app/pods/components/share-custom-template/component.js         | 5 ++++-
 thirdeye/thirdeye-frontend/app/pods/home/share-dashboard/route.js  | 4 +++-
 .../app/pods/services/rootcause-aggregates-cache/service.js        | 4 +++-
 .../app/pods/services/rootcause-breakdowns-cache/service.js        | 4 +++-
 .../app/pods/services/rootcause-timeseries-cache/service.js        | 3 ++-
 thirdeye/thirdeye-frontend/app/utils/build-tooltip.js              | 4 +++-
 thirdeye/thirdeye-frontend/app/utils/rca-utils.js                  | 4 +++-
 thirdeye/thirdeye-frontend/config/environment.js                   | 2 ++
 12 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/thirdeye/thirdeye-frontend/app/pods/application/route.js 
b/thirdeye/thirdeye-frontend/app/pods/application/route.js
index 647c613..5901792 100644
--- a/thirdeye/thirdeye-frontend/app/pods/application/route.js
+++ b/thirdeye/thirdeye-frontend/app/pods/application/route.js
@@ -39,7 +39,7 @@ export default Route.extend(ApplicationRouteMixin, {
         });
     }
 
-    this.get('moment').setTimeZone('America/Los_Angeles');
+    this.get('moment').setTimeZone(config.timeZone);
   },
 
   model(params, transition) {
diff --git 
a/thirdeye/thirdeye-frontend/app/pods/components/alert-details/component.js 
b/thirdeye/thirdeye-frontend/app/pods/components/alert-details/component.js
index 7bd40f0..6e4bd76 100644
--- a/thirdeye/thirdeye-frontend/app/pods/components/alert-details/component.js
+++ b/thirdeye/thirdeye-frontend/app/pods/components/alert-details/component.js
@@ -33,6 +33,7 @@ import floatToPercent from 
'thirdeye-frontend/utils/float-to-percent';
 import { setUpTimeRangeOptions } from 
'thirdeye-frontend/utils/manage-alert-utils';
 import moment from 'moment';
 import _ from 'lodash';
+import config from 'thirdeye-frontend/config/environment';
 
 const TABLE_DATE_FORMAT = 'MMM DD, hh:mm A'; // format for anomaly table
 const TIME_PICKER_INCREMENT = 5; // tells date picker hours field how 
granularly to display time
@@ -695,7 +696,7 @@ export default Component.extend({
         }] : [];
       const startColumn = [{
         template: 'custom/anomalies-table/start-duration',
-        title: 'Start / Duration (PDT)',
+        title: `Start / Duration 
(${moment().tz(config.timeZone).format('z')})`,
         propertyName: 'startDateStr',
         sortedBy: 'start',
         sortDirection: 'desc',
@@ -1154,7 +1155,7 @@ export default Component.extend({
       selectedRule,
       uniqueTimeSeries
     } = this.getProperties('metricUrn', 'analysisRange', 'selectedBaseline', 
'showRules', 'selectedRule', 'uniqueTimeSeries');
-    const timeZone = 'America/Los_Angeles';
+    const timeZone = config.timeZone;
 
     this.setProperties({
       errorTimeseries: null,
diff --git 
a/thirdeye/thirdeye-frontend/app/pods/components/anomaly-summary/component.js 
b/thirdeye/thirdeye-frontend/app/pods/components/anomaly-summary/component.js
index b11a381..0be588a 100644
--- 
a/thirdeye/thirdeye-frontend/app/pods/components/anomaly-summary/component.js
+++ 
b/thirdeye/thirdeye-frontend/app/pods/components/anomaly-summary/component.js
@@ -24,6 +24,7 @@ import { checkStatus, humanizeFloat, buildBounds } from 
'thirdeye-frontend/utils
 import columns from 'thirdeye-frontend/shared/anomaliesTableColumns';
 import moment from 'moment';
 import _ from 'lodash';
+import config from 'thirdeye-frontend/config/environment';
 
 const TABLE_DATE_FORMAT = 'MMM DD, hh:mm A'; // format for anomaly table and 
legend
 
@@ -52,6 +53,12 @@ export default Component.extend({
    * predicted time series
    */
   predicted: null,
+
+  /**
+   * timezone id
+   */
+  timezoneId: moment().tz(config.timeZone).format('z'),
+
   /**
    * imported color mapping for graph
    */
diff --git 
a/thirdeye/thirdeye-frontend/app/pods/components/anomaly-summary/template.hbs 
b/thirdeye/thirdeye-frontend/app/pods/components/anomaly-summary/template.hbs
index 201e6f5..3303c1e 100644
--- 
a/thirdeye/thirdeye-frontend/app/pods/components/anomaly-summary/template.hbs
+++ 
b/thirdeye/thirdeye-frontend/app/pods/components/anomaly-summary/template.hbs
@@ -34,7 +34,7 @@
         <tr class="te-anomaly-table__row te-anomaly-table__head">
           <th class="te-anomaly-table__cell-head 
te-anomaly-table__cell-head--left">
             <a class="te-anomaly-table__cell-link">
-              Start/Duration (PDT)
+              Start/Duration ({{timezoneId}})
             </a>
           </th>
           <th class="te-anomaly-table__cell-head">
diff --git 
a/thirdeye/thirdeye-frontend/app/pods/components/share-custom-template/component.js
 
b/thirdeye/thirdeye-frontend/app/pods/components/share-custom-template/component.js
index c2be191..f816ab2 100644
--- 
a/thirdeye/thirdeye-frontend/app/pods/components/share-custom-template/component.js
+++ 
b/thirdeye/thirdeye-frontend/app/pods/components/share-custom-template/component.js
@@ -28,6 +28,8 @@ import { humanizeFloat, checkStatus } from 
'thirdeye-frontend/utils/utils';
 import moment from 'moment';
 import floatToPercent from 'thirdeye-frontend/utils/float-to-percent';
 import Ember from 'ember';
+import config from 'thirdeye-frontend/config/environment';
+
 
 export default Component.extend({
   classNames: ['share-custom-template'],
@@ -79,6 +81,7 @@ export default Component.extend({
     let index = 0;
     const customHeaderMapping = get(this, 'customHeaderMapping');
     const { start, end } = getProperties(this, 'start', 'end');
+    const timeZone = config.timeZone
 
     for (const entity of entities) {
       if(!customHeaderMapping[index]) {
@@ -96,7 +99,7 @@ export default Component.extend({
           const promiseArray = [];
           if(metrics) {
             for (const metric of metrics) {
-              const offsets = yield 
fetch(`/rootcause/metric/aggregate/batch?urn=${metric}&start=${start}&end=${end}&offsets=${offsetsStr}&timezone=America/Los_Angeles`).then(checkStatus).then(res
 => res);
+              const offsets = yield 
fetch(`/rootcause/metric/aggregate/batch?urn=${metric}&start=${start}&end=${end}&offsets=${offsetsStr}&timezone=${timeZone}`).then(checkStatus).then(res
 => res);
               sumOffsets.push(offsets);
             }
             // assumes maximum of two metrics and compares the two
diff --git a/thirdeye/thirdeye-frontend/app/pods/home/share-dashboard/route.js 
b/thirdeye/thirdeye-frontend/app/pods/home/share-dashboard/route.js
index 1e5c454..2d825c8 100644
--- a/thirdeye/thirdeye-frontend/app/pods/home/share-dashboard/route.js
+++ b/thirdeye/thirdeye-frontend/app/pods/home/share-dashboard/route.js
@@ -14,6 +14,7 @@ import {
 import { appendFilters } from 'thirdeye-frontend/utils/rca-utils';
 import { humanizeFloat, humanizeChange, checkStatus } from 
'thirdeye-frontend/utils/utils';
 import floatToPercent from 'thirdeye-frontend/utils/float-to-percent';
+import config from 'thirdeye-frontend/config/environment';
 
 const queryParamsConfig = {
   refreshModel: true
@@ -169,6 +170,7 @@ export default Route.extend(AuthenticatedRouteMixin, {
           const dimensions = get(anomaly, 'dimensions');
           const start = get(anomaly, 'start');
           const end = get(anomaly, 'end');
+          const timeZone = config.timeZone
 
           if (!map[metricName]) {
             map[metricName] = { 'metricId': metricId, items: {}, count: index 
};
@@ -183,7 +185,7 @@ export default Route.extend(AuthenticatedRouteMixin, {
           //build new urn
           const metricUrn = appendFilters(`thirdeye:metric:${metricId}`, 
filteredDimensions);
           //Get all in the following order - current,wo2w,median4w
-          const offsets = await 
fetch(`/rootcause/metric/aggregate/batch?urn=${metricUrn}&start=${start}&end=${end}&offsets=wo1w,wo2w,median4w&timezone=America/Los_Angeles`).then(checkStatus).then(res
 => res);
+          const offsets = await 
fetch(`/rootcause/metric/aggregate/batch?urn=${metricUrn}&start=${start}&end=${end}&offsets=wo1w,wo2w,median4w&timezone=${timeZone}`).then(checkStatus).then(res
 => res);
 
           const current = get(anomaly, 'current');
           const wow = humanizeFloat(offsets[0]);
diff --git 
a/thirdeye/thirdeye-frontend/app/pods/services/rootcause-aggregates-cache/service.js
 
b/thirdeye/thirdeye-frontend/app/pods/services/rootcause-aggregates-cache/service.js
index 6221342..4e34add 100644
--- 
a/thirdeye/thirdeye-frontend/app/pods/services/rootcause-aggregates-cache/service.js
+++ 
b/thirdeye/thirdeye-frontend/app/pods/services/rootcause-aggregates-cache/service.js
@@ -7,6 +7,8 @@ import {
   makeIterable
 } from 'thirdeye-frontend/utils/rca-utils';
 import { checkStatus } from 'thirdeye-frontend/utils/utils';
+import config from 'thirdeye-frontend/config/environment';
+
 import _ from 'lodash';
 
 const ROOTCAUSE_AGGREGATES_ENDPOINT = '/rootcause/metric/aggregate/chunk';
@@ -109,7 +111,7 @@ export default Service.extend({
     const fetcher = this.get('fetcher');
 
     const [ start, end ] = requestContext.anomalyRange;
-    const timezone = 'America/Los_Angeles';
+    const timezone = config.timeZone;
 
     const url = 
`${ROOTCAUSE_AGGREGATES_ENDPOINT}?urns=${encodeURIComponent(metricUrns)}&start=${start}&end=${end}&offsets=${offsets}&timezone=${timezone}`;
     try {
diff --git 
a/thirdeye/thirdeye-frontend/app/pods/services/rootcause-breakdowns-cache/service.js
 
b/thirdeye/thirdeye-frontend/app/pods/services/rootcause-breakdowns-cache/service.js
index 90eb0b4..9757a23 100644
--- 
a/thirdeye/thirdeye-frontend/app/pods/services/rootcause-breakdowns-cache/service.js
+++ 
b/thirdeye/thirdeye-frontend/app/pods/services/rootcause-breakdowns-cache/service.js
@@ -5,6 +5,8 @@ import {
   toAbsoluteUrn
 } from 'thirdeye-frontend/utils/rca-utils';
 import { checkStatus } from 'thirdeye-frontend/utils/utils';
+import config from 'thirdeye-frontend/config/environment';
+
 import _ from 'lodash';
 
 const ROOTCAUSE_BREAKDOWNS_ENDPOINT = '/rootcause/metric/breakdown';
@@ -93,7 +95,7 @@ export default Service.extend({
     const metricUrn = toMetricUrn(urn);
     const range = context.anomalyRange;
     const offset = toAbsoluteUrn(urn, 
context.compareMode).split(':')[2].toLowerCase();
-    const timezone = 'America/Los_Angeles';
+    const timezone = config.timeZone;
     const limit = offset === 'current' ? 100 : 200; // heuristically 
over-fetch baseline for heat map
 
     const url = 
`${ROOTCAUSE_BREAKDOWNS_ENDPOINT}?urn=${metricUrn}&start=${range[0]}&end=${range[1]}&offset=${offset}&timezone=${timezone}&limit=${limit}`;
diff --git 
a/thirdeye/thirdeye-frontend/app/pods/services/rootcause-timeseries-cache/service.js
 
b/thirdeye/thirdeye-frontend/app/pods/services/rootcause-timeseries-cache/service.js
index 702b24b..171333e 100644
--- 
a/thirdeye/thirdeye-frontend/app/pods/services/rootcause-timeseries-cache/service.js
+++ 
b/thirdeye/thirdeye-frontend/app/pods/services/rootcause-timeseries-cache/service.js
@@ -5,6 +5,7 @@ import {
   toAbsoluteUrn
 } from 'thirdeye-frontend/utils/rca-utils';
 import { checkStatus } from 'thirdeye-frontend/utils/utils';
+import config from 'thirdeye-frontend/config/environment';
 import _ from 'lodash';
 
 const ROOTCAUSE_TIMESERIES_ENDPOINT = '/rootcause/metric/timeseries';
@@ -96,7 +97,7 @@ export default Service.extend({
     const range = context.analysisRange;
     const offset = toAbsoluteUrn(urn, 
context.compareMode).split(':')[2].toLowerCase();
     const granularity = context.granularity;
-    const timezone = 'America/Los_Angeles';
+    const timezone = config.timeZone;
 
     const url = 
`${ROOTCAUSE_TIMESERIES_ENDPOINT}?urn=${metricUrn}&start=${range[0]}&end=${range[1]}&offset=${offset}&granularity=${granularity}&timezone=${timezone}`;
     return fetcher.fetch(url, ROOTCAUSE_TIMESERIES_PRIORITY)
diff --git a/thirdeye/thirdeye-frontend/app/utils/build-tooltip.js 
b/thirdeye/thirdeye-frontend/app/utils/build-tooltip.js
index 172b11e..450600f 100644
--- a/thirdeye/thirdeye-frontend/app/utils/build-tooltip.js
+++ b/thirdeye/thirdeye-frontend/app/utils/build-tooltip.js
@@ -11,6 +11,7 @@ import {
 } from 'thirdeye-frontend/utils/rca-utils';
 import { humanizeChange, humanizeFloat } from 'thirdeye-frontend/utils/utils';
 import moment from 'moment';
+import config from 'thirdeye-frontend/config/environment';
 
 /**
  * Massages the hovered urns
@@ -118,11 +119,12 @@ export default Helper.extend({
     const lookup = getTimeseriesLookup(timeseries, hoverUrns);
     const values = getValues(hoverUrns, hoverTimestamp, lookup, entities);
     const colors = getColors(entities, hoverUrns);
+    const timeZoneId = moment(hoverTimestamp).tz(config.timeZone).format('z')
 
     /** TODO: abstract the js out of the template */
     return htmlSafe(`
       <div class="te-tooltip">
-        <h5 class="te-tooltip__header">${humanTimeStamp} (PDT)</h5>
+        <h5 class="te-tooltip__header">${humanTimeStamp} (${timeZoneId})</h5>
         <div class="te-tooltip__body">
           ${metricUrns.map((urn) => {
             return `
diff --git a/thirdeye/thirdeye-frontend/app/utils/rca-utils.js 
b/thirdeye/thirdeye-frontend/app/utils/rca-utils.js
index 194f3c5..a719b9b 100644
--- a/thirdeye/thirdeye-frontend/app/utils/rca-utils.js
+++ b/thirdeye/thirdeye-frontend/app/utils/rca-utils.js
@@ -1,5 +1,7 @@
 import moment from 'moment';
 import _ from 'lodash';
+import config from 'thirdeye-frontend/config/environment';
+
 
 const ROOTCAUSE_ANALYSIS_DURATION_MAX = 1209600000; // 14 days (in millis)
 const ROOTCAUSE_ANOMALY_DURATION_MAX = 604800000; // 7 days (in millis)
@@ -49,7 +51,7 @@ export const dateFormatFull = 'ddd, MMM D YYYY, h:mm a z';
  */
 export function makeTime(t, args) {
   if (typeof t === 'undefined') { t = moment().valueOf(); }
-  return moment(t, args).tz('America/Los_Angeles');
+  return moment(t, args).tz(config.timeZone);
 }
 
 /**
diff --git a/thirdeye/thirdeye-frontend/config/environment.js 
b/thirdeye/thirdeye-frontend/config/environment.js
index 531ee61..af2e9c0 100644
--- a/thirdeye/thirdeye-frontend/config/environment.js
+++ b/thirdeye/thirdeye-frontend/config/environment.js
@@ -25,6 +25,8 @@ module.exports = function(environment) {
 
     https_only: false,
 
+    timeZone: "America/Los_Angeles",
+
     moment: {
       includeTimezone: 'all'
     },


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to