MCPcopy Create free account
hub / github.com/taskforcesh/bullmq / getRanges

Method getRanges

php/src/Scripts.php:395–420  ·  view source on GitHub ↗

* Get ranges of jobs. * * @param array $types * @param int $start * @param int $end * @param bool $asc * @return array */

(array $types, int $start = 0, int $end = 1, bool $asc = false)

Source from the content-addressed store, hash-verified

393 * @return array<string>
394 */
395 public function getRanges(array $types, int $start = 0, int $end = 1, bool $asc = false): array
396 {
397 $transformedTypes = array_map(
398 fn($type) => $type === 'waiting' ? 'wait' : $type,
399 $types
400 );
401
402 $keys = $this->getKeys(['']);
403 $args = [$start, $end, $asc ? '1' : '0', ...$transformedTypes];
404
405 $result = $this->execScript('getRanges-1.lua', $keys, $args);
406
407 if (!is_array($result)) {
408 return [];
409 }
410
411 // Flatten the results
412 $jobIds = [];
413 foreach ($result as $response) {
414 if (is_array($response)) {
415 $jobIds = array_merge($jobIds, $response);
416 }
417 }
418
419 return array_unique($jobIds);
420 }
421
422 /**
423 * Clean jobs from a set.

Callers

nothing calls this directly

Calls 2

getKeysMethod · 0.95
execScriptMethod · 0.95

Tested by

no test coverage detected