[Telem] ensure request has minimum fields

Ensure telemetry request options always have a certain number
of fields-- start, end, and domain.  This allows telemetry providers
to implement necessary filtering for these types of requests.
This commit is contained in:
Pete Richards 2017-05-10 17:22:01 -07:00
parent 6481ddbd7f
commit 6310be623a

View File

@ -196,6 +196,21 @@ define([
return this.requestProviders.filter(supportsDomainObject)[0];
};
/**
* @private
*/
TelemetryAPI.prototype.standardizeRequestOptions = function (options) {
if (!options.hasOwnProperty('start')) {
options.start = this.MCT.time.bounds().start;
}
if (!options.hasOwnProperty('end')) {
options.end = this.MCT.time.bounds().end;
}
if (!options.hasOwnProperty('domain')) {
options.domain = this.MCT.time.timeSystem().key;
}
};
/**
* Request historical telemetry for a domain object.
* The `options` argument allows you to specify filters
@ -212,6 +227,7 @@ define([
* telemetry data
*/
TelemetryAPI.prototype.request = function (domainObject, options) {
this.standardizeRequestOptions(options);
var provider = this.findRequestProvider.apply(this, arguments);
return provider.request.apply(provider, arguments);
};