<commit_before><?php
/**
* ResqueScheduler core class to handle scheduling of jobs in the future.
*
* @package		ResqueScheduler
* @author		<NAME> <<EMAIL>>
* @copyright	(c) 2012 <NAME>
* @license		http://www.opensource.org/licenses/mit-license.php
*/
namespace Kamisama\ResqueScheduler;

class ResqueScheduler
{

    const QUEUE_NAME = '_scheduler_';

    /**
     * Enqueue a job in a given number of seconds from now.
     *
     * Identical to Resque::enqueue, however the first argument is the number
     * of seconds before the job should be executed.
     *
     * @param int     $in          Number of seconds from now when the job should be executed.
     * @param string  $queue       The name of the queue to place the job in.
     * @param string  $class       The name of the class that contains the code to execute the job.
     * @param array   $args        Any optional arguments that should be passed when the job is executed.
     * @param boolean $trackStatus Set to true to be able to monitor the status of a job.
     */
    public static function enqueueIn($in, $queue, $class, array $args = array(), $trackStatus = false)
    {
        self::enqueueAt(time() + $in, $queue, $class, $args, $trackStatus);
    }

    /**
     * Enqueue a job for execution at a given timestamp.
     *
     * Identical to Resque::enqueue, however the first argument is a timestamp
     * (either UNIX timestamp in integer format or an instance of the DateTime
     * class in PHP).
     *
     * @param DateTime|int $at          Instance of PHP DateTime object or int of UNIX timestamp.
     * @param string       $queue       The name of the queue to place the job in.
     * @param string       $class       The name of the class that contains the code to execute the job.
     * @param array        $args        Any optional arguments that should be passed when the job is executed.
     * @param boolean      $trackStatus Set to true to be able to monitor the status of a job. *
     */
    public static function enqueueAt($at, $queue, $class, $args = array(), $trackStatus = false)
    {
        self::validateJob($class, $queue);

        $job = self::jobToHash($queue, $class, $args, $trackStatus);
        self::delayedPush($at, $job);

        \Resque_Event::trigger(
            'afterSchedule',
            array(
                'at'    => $at,
                'queue' => $queue,
                'class' => $class,
                'args'  => $args,
            )
        );
    }

    /**
     * Directly append an item to the delayed queue schedule.<commit_msg>Add status tracker for Scheduled jobs<commit_after><?php
/**
* ResqueScheduler core class to handle scheduling of jobs in the future.
*
* @package		ResqueScheduler
* @author		<NAME> <<EMAIL>> (Original)
* @author      <NAME> <<EMAIL>>
* @copyright	(c) 2012 <NAME>
* @license		http://www.opensource.org/licenses/mit-license.php
*/
namespace Kamisama\ResqueScheduler;

class ResqueScheduler
{
    // Name of the scheduler queue
    // Should be as unique as possible
    const QUEUE_NAME = '_schdlr_';

    /**
     * Enqueue a job in a given number of seconds from now.
     *
     * Identical to Resque::enqueue, however the first argument is the number
     * of seconds before the job should be executed.
     *
     * @param   int     $in             Number of seconds from now when the job should be executed.
     * @param   string  $queue          The name of the queue to place the job in.
     * @param   string  $class          The name of the class that contains the code to execute the job.
     * @param   array   $args           Any optional arguments that should be passed when the job is executed.
     * @param   boolean $trackStatus    Set to true to be able to monitor the status of a job.
     * @return  string                  Job ID
     */
    public static function enqueueIn($in, $queue, $class, array $args = array(), $trackStatus = false)
    {
        return self::enqueueAt(time() + $in, $queue, $class, $args, $trackStatus);
    }

    /**
     * Enqueue a job for execution at a given timestamp.
     *
     * Identical to Resque::enqueue, however the first argument is a timestamp
     * (either UNIX timestamp in integer format or an instance of the DateTime
     * class in PHP).
     *
     * @param   DateTime|int $at            Instance of PHP DateTime object or int of UNIX timestamp.
     * @param   string       $queue         The name of the queue to place the job in.
     * @param   string       $class         The name of the class that contains the code to execute the job.
     * @param   array        $args          Any optional arguments that should be passed when the job is executed.
     * @param   boolean      $trackStatus   Set to true to be able to monitor the status of a job.
     * @return  string                      Job ID
     */
    public static function enqueueAt($at, $queue, $class, $args = array(), $trackStatus = false)
    {
        self::validateJob($class, $queue);

        $args['id'] = md5(uniqid('', true));
        $job = self::jobToHash($queue, $class, $args, $trackStatus);
        self::delayedPush($at, $job);

        if ($trackStatus) {
            \Resque_Job_Status::create($args['id'], Job\Status::STATUS_SCHEDULED);
        }

        \Resque_Event::trigger(
            'afterSchedule',
            array(
                'at'    => $at,
                'queue' => $queue,
                'class' => $class,
                'args'  => $args,
            )
        );

        return $args['id'];
    }

    /**
     * Directly append an item to the delayed queue schedule.
{'fraction_non_alphanumeric': 0.09629366909026423, 'fraction_numerical': 0.0015960276644795177, 'mean_word_length': 2.1525992174399105, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5158105', 'n_tokens_mistral': 1582, 'n_tokens_neox': 1544, 'n_words': 629}