[Imagery] Issue #1962 - History shows oldest image (#1983)

* force update to latest image when history is received

* force update to latest history image on response received

* remove console log"

* change requestLAD function to last item in array, in case response is an array with more than one item

* fix checkstyle

* remove requestLAD because its requesting history twice in cases where server does not have latest flag
This commit is contained in:
Deep Tailor 2018-04-20 09:15:25 -07:00 committed by Pete Richards
parent 75ae5ab3bb
commit 8c739e9fd9
2 changed files with 11 additions and 34 deletions

View File

@ -92,7 +92,7 @@ define(
this.updateHistory(datum);
this.updateValues(datum);
}.bind(this));
this.requestLad(false);
this.requestHistory(this.openmct.time.bounds());
}.bind(this));
};
@ -107,34 +107,13 @@ define(
if (this.requestCount > requestId) {
return Promise.resolve('Stale request');
}
values.forEach(function (datum) {
this.updateHistory(datum);
}, this);
this.requestLad(true);
}.bind(this));
};
/**
* Makes a request for the most recent datum in the
* telelmetry store. Optional addToHistory argument
* determines whether the requested telemetry should
* be added to history or only used to update the current
* image url and timestamp.
* @private
* @param {boolean} [addToHistory] if true, adds to history
*/
ImageryController.prototype.requestLad = function (addToHistory) {
this.openmct.telemetry
.request(this.domainObject, {
strategy: 'latest',
size: 1
})
.then(function (values) {
this.updateValues(values[0]);
if (addToHistory !== false) {
this.updateHistory(values[0]);
}
}.bind(this));
this.updateValues(values[values.length - 1]);
}.bind(this));
};
ImageryController.prototype.stopListening = function () {

View File

@ -59,7 +59,8 @@ define(
'timeSystem',
'clock',
'on',
'off'
'off',
'bounds'
]),
telemetry: jasmine.createSpyObj('telemetryAPI', [
'subscribe',
@ -118,7 +119,8 @@ define(
describe("when loaded", function () {
var callback,
boundsListener;
boundsListener,
bounds;
beforeEach(function () {
waitsFor(function () {
@ -137,13 +139,9 @@ define(
});
});
it("uses LAD telemetry", function () {
it("requests history", function () {
expect(openmct.telemetry.request).toHaveBeenCalledWith(
newDomainObject,
{
strategy: 'latest',
size: 1
}
newDomainObject, bounds
);
expect(controller.getTime()).toEqual(prefix + 1434600258123);
expect(controller.getImageUrl()).toEqual('some/url');
@ -204,7 +202,7 @@ define(
it("requests telemetry", function () {
expect(openmct.telemetry.request).toHaveBeenCalledWith(
newDomainObject,
jasmine.any(Object)
bounds
);
});