MCPcopy Index your code
hub / github.com/bee-queue/bee-queue / _addJobsByIds

Method _addJobsByIds

lib/queue.js:357–380  ·  view source on GitHub ↗
(jobs, ids)

Source from the content-addressed store, hash-verified

355 }
356
357 _addJobsByIds(jobs, ids) {
358 // We need to re-ensure the queue is commandable, as we might be shutting
359 // down during this operation.
360 return this._commandable()
361 .then((client) => {
362 const got = helpers.deferred();
363 const commandArgs = [this.toKey('jobs')].concat(ids, got.defer());
364 client.hmget.apply(client, commandArgs);
365 return got;
366 })
367 .then((dataArray) => {
368 const count = ids.length;
369 // Some jobs returned by the scan may have already been removed, so
370 // filter them out.
371 for (let i = 0; i < count; ++i) {
372 const jobData = dataArray[i];
373 /* istanbul ignore else: not worth unit-testing this edge case */
374 if (jobData) {
375 jobs.push(Job.fromData(this, ids[i], jobData));
376 }
377 }
378 return jobs;
379 });
380 }
381
382 /**
383 * Get jobs from queue type.

Callers 1

getJobsMethod · 0.95

Calls 3

_commandableMethod · 0.95
toKeyMethod · 0.95
fromDataMethod · 0.80

Tested by

no test coverage detected