Ensure that datum that is of type array is formatted as such (#6467)

* Ensure that datum that is of type array is formatted as such
* Ensure the requestEnded event is emitted even when historicalData is empty.
This commit is contained in:
Shefali Joshi 2023-03-17 14:22:51 -07:00 committed by GitHub
parent a3c5450205
commit 1b7fb9b952
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -130,9 +130,6 @@ export default class TelemetryCollection extends EventEmitter {
this.emit('requestStarted');
const modifiedOptions = await this.openmct.telemetry.applyRequestInterceptors(this.domainObject, options);
historicalData = await historicalProvider.request(this.domainObject, modifiedOptions);
if (!historicalData || !historicalData.length) {
return;
}
} catch (error) {
if (error.name !== 'AbortError') {
console.error('Error requesting telemetry data...');
@ -143,6 +140,10 @@ export default class TelemetryCollection extends EventEmitter {
this.emit('requestEnded');
this.requestAbort = undefined;
if (!historicalData || !historicalData.length) {
return;
}
this._processNewTelemetry(historicalData);
}

View File

@ -121,8 +121,9 @@ define([
}
TelemetryValueFormatter.prototype.parse = function (datum) {
const isDatumArray = Array.isArray(datum);
if (_.isObject(datum)) {
const objectDatum = datum[this.valueMetadata.source];
const objectDatum = isDatumArray ? datum : datum[this.valueMetadata.source];
if (Array.isArray(objectDatum)) {
return objectDatum.map((item) => {
return this.formatter.parse(item);
@ -136,8 +137,9 @@ define([
};
TelemetryValueFormatter.prototype.format = function (datum) {
const isDatumArray = Array.isArray(datum);
if (_.isObject(datum)) {
const objectDatum = datum[this.valueMetadata.source];
const objectDatum = isDatumArray ? datum : datum[this.valueMetadata.source];
if (Array.isArray(objectDatum)) {
return objectDatum.map((item) => {
return this.formatter.format(item);