[courier/requestQueue] fix get(), added getStartable()
get() implies that it will get all pending requests that match a strategy, but it is actually filtering by wether a require is startable. Added getStartable() to accomplish that task and get() now returns all requests that match a strategy.
This commit is contained in:
parent
1a29624c00
commit
88a1cd929a
4 changed files with 8 additions and 6 deletions
|
@ -16,8 +16,11 @@ define(function (require) {
|
|||
});
|
||||
};
|
||||
|
||||
queue.get = function (/* strategies.. */) {
|
||||
var strategies = _.toArray(arguments);
|
||||
queue.getStartable = function (...strategies) {
|
||||
return queue.get(...strategies).filter(req => req.canStart());
|
||||
};
|
||||
|
||||
queue.get = function (...strategies) {
|
||||
return queue.filter(function (req) {
|
||||
var strategyMatch = !strategies.length;
|
||||
if (!strategyMatch) {
|
||||
|
@ -26,7 +29,7 @@ define(function (require) {
|
|||
});
|
||||
}
|
||||
|
||||
return strategyMatch && req.canStart();
|
||||
return strategyMatch;
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -203,7 +203,7 @@ define(function (require) {
|
|||
*****/
|
||||
|
||||
SourceAbstract.prototype._myQueued = function () {
|
||||
var reqs = requestQueue.get(this._fetchStrategy);
|
||||
var reqs = requestQueue.getStartable(this._fetchStrategy);
|
||||
return _.where(reqs, { source: this });
|
||||
};
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ define(function (require) {
|
|||
var INCOMPLETE = Private(require('ui/courier/fetch/_req_status')).INCOMPLETE;
|
||||
|
||||
function fetchQueued(strategy) {
|
||||
var requests = requestQueue.get(strategy);
|
||||
var requests = requestQueue.getStartable(strategy);
|
||||
if (!requests.length) return Promise.resolve();
|
||||
else return fetchThese(requests);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ define(function (require) {
|
|||
return function CourierSegmentedReqProvider(es, Private, Promise, Notifier, timefilter, config) {
|
||||
var _ = require('lodash');
|
||||
var SearchReq = Private(require('ui/courier/fetch/request/search'));
|
||||
var requestQueue = Private(require('ui/courier/_request_queue'));
|
||||
var SegmentedHandle = Private(require('ui/courier/fetch/request/_segmented_handle'));
|
||||
|
||||
var notify = new Notifier({
|
||||
|
|
Loading…
Reference in a new issue