From 45a152df86698066f9a5163917fb953d3e40b43d Mon Sep 17 00:00:00 2001 From: Andrew Henry Date: Thu, 21 Jun 2018 10:50:43 -0700 Subject: [PATCH] Build columns from union of telemetry value metadata. (#2075) * Build columns from union of telemetry value metadata. Do not manually clean up scope. Fixes #2027. Fixes #1884. Fixes #1817. * Fixed tests that are failing on circle-ci * Inlined getMetadataValues function --- .../commonUI/formats/src/UTCTimeFormat.js | 4 +++- .../src/controllers/MCTTableController.js | 4 ---- .../controllers/TelemetryTableController.js | 19 +++++++++---------- .../TelemetryTableControllerSpec.js | 12 ++++++++++-- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/platform/commonUI/formats/src/UTCTimeFormat.js b/platform/commonUI/formats/src/UTCTimeFormat.js index 6339bb0266..6f839241f6 100644 --- a/platform/commonUI/formats/src/UTCTimeFormat.js +++ b/platform/commonUI/formats/src/UTCTimeFormat.js @@ -115,8 +115,10 @@ define([ UTCTimeFormat.prototype.format = function (value) { if (arguments.length > 1) { return getScaledFormat(value); - } else { + } else if (value !== undefined) { return moment.utc(value).format(DATE_FORMAT) + "Z"; + } else { + return value; } }; diff --git a/platform/features/table/src/controllers/MCTTableController.js b/platform/features/table/src/controllers/MCTTableController.js index 9d814b4c7a..80fac94e66 100644 --- a/platform/features/table/src/controllers/MCTTableController.js +++ b/platform/features/table/src/controllers/MCTTableController.js @@ -180,10 +180,6 @@ define( this.scrollable.off('scroll', this.onScroll); this.destroyConductorListeners(); - // In case for some reason this controller instance lingers around, - // destroy scope as it can be extremely large for large tables. - delete this.$scope; - }.bind(this)); } diff --git a/platform/features/table/src/controllers/TelemetryTableController.js b/platform/features/table/src/controllers/TelemetryTableController.js index 757ad668a1..5a51eb53ff 100644 --- a/platform/features/table/src/controllers/TelemetryTableController.js +++ b/platform/features/table/src/controllers/TelemetryTableController.js @@ -226,12 +226,6 @@ define( if (this.timeoutHandle) { this.$timeout.cancel(this.timeoutHandle); } - - // In case controller instance lingers around (currently there is a - // temporary memory leak with PlotController), clean up scope as it - // can be extremely large. - this.$scope = null; - this.table = null; }; /** @@ -246,12 +240,16 @@ define( this.$scope.headers = []; if (objects.length > 0) { - var metadatas = objects.map(telemetryApi.getMetadata.bind(telemetryApi)); - var allColumns = telemetryApi.commonValuesForHints(metadatas, []); + var allMetadata = objects.map(telemetryApi.getMetadata.bind(telemetryApi)); + var allValueMetadata = _.flatten(allMetadata.map( + function getMetadataValues(metadata) { + return metadata.values(); + } + )); - this.table.populateColumns(allColumns); + this.table.populateColumns(allValueMetadata); - var domainColumns = telemetryApi.commonValuesForHints(metadatas, ['domain']); + var domainColumns = telemetryApi.commonValuesForHints(allMetadata, ['domain']); this.timeColumns = domainColumns.map(function (metadatum) { return metadatum.name; }); @@ -269,6 +267,7 @@ define( } } + return objects; }; diff --git a/platform/features/table/test/controllers/TelemetryTableControllerSpec.js b/platform/features/table/test/controllers/TelemetryTableControllerSpec.js index 509d38ef71..db2f2f5876 100644 --- a/platform/features/table/test/controllers/TelemetryTableControllerSpec.js +++ b/platform/features/table/test/controllers/TelemetryTableControllerSpec.js @@ -116,7 +116,11 @@ define( formatter.parse.andCallFake(getter); return formatter; }); - + mockTelemetryAPI.getMetadata.andReturn({ + values: function () { + return []; + } + }); mockTelemetryAPI.isTelemetryObject.andReturn(false); mockTimeout = jasmine.createSpy("timeout"); @@ -363,7 +367,11 @@ define( mockTelemetryAPI.commonValuesForHints.andCallFake(function (metadata, hints) { if (_.eq(hints, ["domain"])) { return domainMetadata; - } else if (_.eq(hints, [])) { + } + }); + + mockTelemetryAPI.getMetadata.andReturn({ + values: function () { return allMetadata; } });