ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From onechipore...@apache.org
Subject ambari git commit: AMBARI-13387. Improve time for transforming data on the graphs (onechiporenko)
Date Mon, 12 Oct 2015 13:17:14 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 c68074f78 -> 7ba85ef21


AMBARI-13387. Improve time for transforming data on the graphs (onechiporenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/7ba85ef2
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7ba85ef2
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7ba85ef2

Branch: refs/heads/branch-2.1
Commit: 7ba85ef214715304e2c7c714f654f6774d831121
Parents: c68074f
Author: Oleg Nechiporenko <onechiporenko@apache.org>
Authored: Fri Oct 9 16:44:07 2015 +0300
Committer: Oleg Nechiporenko <onechiporenko@apache.org>
Committed: Mon Oct 12 16:17:02 2015 +0300

----------------------------------------------------------------------
 .../app/views/common/chart/linear_time.js       |  8 +++--
 .../test/views/common/chart/linear_time_test.js | 38 ++++++++++++++------
 2 files changed, 34 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/7ba85ef2/ambari-web/app/views/common/chart/linear_time.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/chart/linear_time.js b/ambari-web/app/views/common/chart/linear_time.js
index 8e903d6..fcb686c 100644
--- a/ambari-web/app/views/common/chart/linear_time.js
+++ b/ambari-web/app/views/common/chart/linear_time.js
@@ -325,10 +325,10 @@ App.ChartLinearTimeView = Ember.View.extend(App.ExportMetricsMixin,
{
       var series = {};
       series.name = displayName;
       series.data = [];
+      var timeDiff = App.dateTimeWithTimeZone(seriesData[0][1] * 1000) / 1000 - seriesData[0][1];
       for (var index = 0; index < seriesData.length; index++) {
-        var x = App.dateTimeWithTimeZone(seriesData[index][1] * 1000) / 1000;
         series.data.push({
-          x: x,
+          x: seriesData[index][1] + timeDiff,
           y: seriesData[index][0]
         });
       }
@@ -394,6 +394,7 @@ App.ChartLinearTimeView = Ember.View.extend(App.ExportMetricsMixin, {
     if (this.get('isDestroyed')) {
       return;
     }
+    console.time('_refreshGraph');
     var seriesData = this.transformToSeries(jsonData);
 
     //if graph opened as modal popup
@@ -438,6 +439,7 @@ App.ChartLinearTimeView = Ember.View.extend(App.ExportMetricsMixin, {
     graph_container = null;
     container = null;
     popup_path = null;
+    console.timeEnd('_refreshGraph');
   },
 
   /**
@@ -1226,9 +1228,11 @@ App.ChartLinearTimeView.LoadAggregator = Em.Object.create({
             hostName: hostName
           }
         }).done(function (response) {
+          console.time('==== runRequestsDone');
           _request.subRequests.forEach(function (subRequest) {
             subRequest.context._refreshGraph.call(subRequest.context, response);
           }, this);
+          console.timeEnd('==== runRequestsDone');
         }).fail(function (jqXHR, textStatus, errorThrown) {
           _request.subRequests.forEach(function (subRequest) {
             subRequest.context.loadDataErrorCallback.call(subRequest.context, jqXHR, textStatus,
errorThrown);

http://git-wip-us.apache.org/repos/asf/ambari/blob/7ba85ef2/ambari-web/test/views/common/chart/linear_time_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/chart/linear_time_test.js b/ambari-web/test/views/common/chart/linear_time_test.js
index 7730e9c..8ac7703 100644
--- a/ambari-web/test/views/common/chart/linear_time_test.js
+++ b/ambari-web/test/views/common/chart/linear_time_test.js
@@ -23,24 +23,35 @@ describe('App.ChartLinearTimeView', function () {
 
   var chartLinearTimeView = App.ChartLinearTimeView.create({});
 
-  describe('#transformData ([[1, 2], [2, 3], [3, 4]], "abc")', function () {
+  describe('#transformData', function () {
+
+    var result;
+
+    beforeEach(function () {
+      var data = [[1, 1200000000], [2, 1200000000], [3, 1200000000]];
+      var name = 'abc';
+      sinon.stub(App.router, 'get').withArgs('userSettingsController.userSettings.timezone').returns('Canada/Atlantic');
+      result = chartLinearTimeView.transformData(data, name);
+    });
+
+    afterEach(function () {
+      App.router.get.restore();
+    });
 
-    var data = [[1, 2], [2, 3], [3, 4]];
-    var name = 'abc';
-    var result = chartLinearTimeView.transformData(data, name);
     it('"name" should be "abc" ', function () {
       expect(result.name).to.equal('abc');
     });
+
     it('data size should be 3 ', function () {
       expect(result.data.length).to.equal(3);
     });
-    it('data[0].x should be 2 ', function () {
-      expect(result.data[0].x).to.equal(2);
-    });
+
     it('data[0].y should be 1 ', function () {
       expect(result.data[0].y).to.equal(1);
     })
-  }),
+
+  });
+
   describe('#yAxisFormatter', function() {
     var tests = [
       {m:'undefined to 0',i:undefined,e:0},
@@ -58,7 +69,8 @@ describe('App.ChartLinearTimeView', function () {
         expect(chartLinearTimeView.yAxisFormatter(test.i)).to.equal(test.e);
       });
     });
-  }),
+  });
+
   describe('#checkSeries', function() {
     var tests = [
       {m:'undefined - false',i:undefined,e:false},
@@ -73,7 +85,8 @@ describe('App.ChartLinearTimeView', function () {
         expect(chartLinearTimeView.checkSeries(test.i)).to.equal(test.e);
       });
     });
-  }),
+  });
+
   describe('#BytesFormatter', function() {
     var tests = [
       {m:'undefined to "0 B"',i:undefined,e:'0 B'},
@@ -94,6 +107,7 @@ describe('App.ChartLinearTimeView', function () {
       });
     });
   });
+
   describe('#PercentageFormatter', function() {
     var tests = [
       {m:'undefined to "0 %"',i:undefined,e:'0 %'},
@@ -110,6 +124,7 @@ describe('App.ChartLinearTimeView', function () {
       });
     });
   });
+
   describe('#TimeElapsedFormatter', function() {
     var tests = [
       {m:'undefined to "0 ms"',i:undefined,e:'0 ms'},
@@ -250,10 +265,12 @@ describe('App.ChartLinearTimeView', function () {
     });
 
   });
+
 });
 
 
 describe('App.ChartLinearTimeView.LoadAggregator', function () {
+
   var aggregator = App.ChartLinearTimeView.LoadAggregator;
 
   describe("#add()", function () {
@@ -368,4 +385,5 @@ describe('App.ChartLinearTimeView.LoadAggregator', function () {
       expect(aggregator.formatRequestData(request)).to.equal('f3[400,4000,15],f4[400,4000,15]');
     });
   });
+
 });


Mime
View raw message