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
This commit is contained in:
Andrew Henry
2018-06-21 10:50:43 -07:00
committed by Pete Richards
parent a3e78bbf91
commit 45a152df86
4 changed files with 22 additions and 17 deletions

View File

@ -115,8 +115,10 @@ define([
UTCTimeFormat.prototype.format = function (value) { UTCTimeFormat.prototype.format = function (value) {
if (arguments.length > 1) { if (arguments.length > 1) {
return getScaledFormat(value); return getScaledFormat(value);
} else { } else if (value !== undefined) {
return moment.utc(value).format(DATE_FORMAT) + "Z"; return moment.utc(value).format(DATE_FORMAT) + "Z";
} else {
return value;
} }
}; };

View File

@ -180,10 +180,6 @@ define(
this.scrollable.off('scroll', this.onScroll); this.scrollable.off('scroll', this.onScroll);
this.destroyConductorListeners(); 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)); }.bind(this));
} }

View File

@ -226,12 +226,6 @@ define(
if (this.timeoutHandle) { if (this.timeoutHandle) {
this.$timeout.cancel(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 = []; this.$scope.headers = [];
if (objects.length > 0) { if (objects.length > 0) {
var metadatas = objects.map(telemetryApi.getMetadata.bind(telemetryApi)); var allMetadata = objects.map(telemetryApi.getMetadata.bind(telemetryApi));
var allColumns = telemetryApi.commonValuesForHints(metadatas, []); 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) { this.timeColumns = domainColumns.map(function (metadatum) {
return metadatum.name; return metadatum.name;
}); });
@ -269,6 +267,7 @@ define(
} }
} }
return objects; return objects;
}; };

View File

@ -116,7 +116,11 @@ define(
formatter.parse.andCallFake(getter); formatter.parse.andCallFake(getter);
return formatter; return formatter;
}); });
mockTelemetryAPI.getMetadata.andReturn({
values: function () {
return [];
}
});
mockTelemetryAPI.isTelemetryObject.andReturn(false); mockTelemetryAPI.isTelemetryObject.andReturn(false);
mockTimeout = jasmine.createSpy("timeout"); mockTimeout = jasmine.createSpy("timeout");
@ -363,7 +367,11 @@ define(
mockTelemetryAPI.commonValuesForHints.andCallFake(function (metadata, hints) { mockTelemetryAPI.commonValuesForHints.andCallFake(function (metadata, hints) {
if (_.eq(hints, ["domain"])) { if (_.eq(hints, ["domain"])) {
return domainMetadata; return domainMetadata;
} else if (_.eq(hints, [])) { }
});
mockTelemetryAPI.getMetadata.andReturn({
values: function () {
return allMetadata; return allMetadata;
} }
}); });