<commit_before><?php

/*
 * This file is part of the Subway package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Subway\Queue;

use Subway\Queue;
use Subway\Message;
use Predis\Client;

/**
 * Delayed queue class
 */
class DelayedQueue extends Queue
{
    /**
     * Class constructor
     *
     * @param Client $redis
     * @param string $name
     */
    public function __construct(Client $redis, $name = 'delayed')
    {
        parent::__construct($redis, $name);
    }

    /**
     * {@inheritdoc}
     */
    public function create()
    {
        return true;
    }

    /**
     * {@inheritdoc}
     */
    public function clear()
    {
        $timestamps = $this->redis->zrangebyscore(sprintf('resque:%s_queue_schedule', $this->getName()), '-inf', 'inf');
        foreach ($timestamps as $timestamp) {
            $this->redis->del(sprintf('resque:%s:%s', $this->getName(), $timestamp));    
        }
        $this->redis->del(sprintf('resque:%s_queue_schedule', $this->getName()));
    }

    /**
     * {@inheritdoc}
     */
    public function count()
    {
        $count = 0;
        $timestamps = $this->redis->zrangebyscore(sprintf('resque:%s_queue_schedule', $this->getName()), '-inf', 'inf');
        foreach ($timestamps as $timestamp) {
            $count += $this->redis->llen(sprintf('resque:%s:%s', $this->getName(), $timestamp));
        }

        return $count;
    }

    /**
     * {@inheritdoc}
     */
    public function getJobs()
    {
        $jobs = array();
        $timestamps = $this->redis->zrangebyscore(sprintf('resque:%s_queue_schedule', $this->getName()), '-inf', 'inf');
        foreach ($timestamps as $timestamp) {
            $items = $this->redis->lrange(sprintf('resque:queue:%s', $this->getName()), 0, -1) ?: array();
            foreach ($items as $item) {
                $jobs[] = Message::jsonUnserialize($item);
            }
        }

        return $jobs;
    }<commit_msg>Delayed queue get jobs bug fixed<commit_after><?php

/*
 * This file is part of the Subway package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Subway\Queue;

use Subway\Queue;
use Subway\Message;
use Predis\Client;

/**
 * Delayed queue class
 */
class DelayedQueue extends Queue
{
    /**
     * Class constructor
     *
     * @param Client $redis
     * @param string $name
     */
    public function __construct(Client $redis, $name = 'delayed')
    {
        parent::__construct($redis, $name);
    }

    /**
     * {@inheritdoc}
     */
    public function create()
    {
        return true;
    }

    /**
     * {@inheritdoc}
     */
    public function clear()
    {
        $timestamps = $this->redis->zrangebyscore(sprintf('resque:%s_queue_schedule', $this->getName()), '-inf', 'inf');
        foreach ($timestamps as $timestamp) {
            $this->redis->del(sprintf('resque:%s:%s', $this->getName(), $timestamp));    
        }
        $this->redis->del(sprintf('resque:%s_queue_schedule', $this->getName()));
    }

    /**
     * {@inheritdoc}
     */
    public function count()
    {
        $count = 0;
        $timestamps = $this->redis->zrangebyscore(sprintf('resque:%s_queue_schedule', $this->getName()), '-inf', 'inf');
        foreach ($timestamps as $timestamp) {
            $count += $this->redis->llen(sprintf('resque:%s:%s', $this->getName(), $timestamp));
        }

        return $count;
    }

    /**
     * {@inheritdoc}
     */
    public function getJobs()
    {
        $jobs = array();
        $timestamps = $this->redis->zrangebyscore(sprintf('resque:%s_queue_schedule', $this->getName()), '-inf', 'inf');
        foreach ($timestamps as $timestamp) {
            $items = $this->redis->lrange(sprintf('resque:%s:%s', $this->getName(), $timestamp), 0, -1);
            foreach ($items as $item) {
                $jobs[] = Message::jsonUnserialize($item);
            }
        }

        return $jobs;
    }
{'fraction_non_alphanumeric': 0.17297949336550061, 'fraction_numerical': 0.0014475271411338963, 'mean_word_length': 2.3844897959183675, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2743298', 'n_tokens_mistral': 1302, 'n_tokens_neox': 1288, 'n_words': 277}