<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\Command;

use React\EventLoop\Factory as React;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/**
 * Status command
 */
class StatusCommand extends ConfigAwareCommand
{
    /**
     * {@inheritdoc}
     */
    protected function configure()
    {
        $this
            ->setName('status')
            ->setDescription('Show subway status')
            ->addOption('live', 'l', InputOption::VALUE_NONE, 'Live status')
        ;
    }

    /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {   
        $output->writeln(json_encode(array(
            'queue'  => $this->queueStatus($input, $output),
            'worker' => $this->workerStatus($input, $output)
        ), JSON_PRETTY_PRINT));
    }

    /**
     * Queue status
     * 
     * @return array
     */
    protected function queueStatus()
    {
        $rows = array();

        foreach ($this->getFactory()->getQueues() as $queue) {
            $rows[$queue->getName()] = $queue->count();
        }

        $delayedQueue   = $this->getFactory()->getDelayedQueue();
        $repeatingQueue = $this->getFactory()->getRepeatingQueue();

        if ($delayedCount = $delayedQueue->count()) {
            $rows[$delayedQueue->getName()] = $delayedCount;
        }

        if ($repeatingCount = $repeatingQueue->count()) {
            $rows[$repeatingQueue->getName()] = $repeatingCount;
        }

        return $rows;
    }

    /**
     * Worker status
     * 
     * @return array
     */
    protected function workerStatus()
    {
        $rows = array();

        foreach ($this->getFactory()->getWorkers() as $worker) {
            list($host, $pid, $queues) = explode(':', $worker);
            $rows[] = array(
                'host'   => $host,
                'pid'    => $pid,
                'queues' => $queues,
            );
        }

        return $rows;
    }
}
<commit_msg>[Minor] Unused use statement removed<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\Command;

use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/**
 * Status command
 */
class StatusCommand extends ConfigAwareCommand
{
    /**
     * {@inheritdoc}
     */
    protected function configure()
    {
        $this
            ->setName('status')
            ->setDescription('Show subway status')
            ->addOption('live', 'l', InputOption::VALUE_NONE, 'Live status')
        ;
    }

    /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {   
        $output->writeln(json_encode(array(
            'queue'  => $this->queueStatus($input, $output),
            'worker' => $this->workerStatus($input, $output)
        ), JSON_PRETTY_PRINT));
    }

    /**
     * Queue status
     * 
     * @return array
     */
    protected function queueStatus()
    {
        $rows = array();

        foreach ($this->getFactory()->getQueues() as $queue) {
            $rows[$queue->getName()] = $queue->count();
        }

        $delayedQueue   = $this->getFactory()->getDelayedQueue();
        $repeatingQueue = $this->getFactory()->getRepeatingQueue();

        if ($delayedCount = $delayedQueue->count()) {
            $rows[$delayedQueue->getName()] = $delayedCount;
        }

        if ($repeatingCount = $repeatingQueue->count()) {
            $rows[$repeatingQueue->getName()] = $repeatingCount;
        }

        return $rows;
    }

    /**
     * Worker status
     * 
     * @return array
     */
    protected function workerStatus()
    {
        $rows = array();

        foreach ($this->getFactory()->getWorkers() as $worker) {
            list($host, $pid, $queues) = explode(':', $worker);
            $rows[] = array(
                'host'   => $host,
                'pid'    => $pid,
                'queues' => $queues,
            );
        }

        return $rows;
    }
}

{'fraction_non_alphanumeric': 0.14926357441195867, 'fraction_numerical': 0.0, 'mean_word_length': 2.101567825494206, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 59, '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': '654326', 'n_tokens_mistral': 1328, 'n_tokens_neox': 1302, 'n_words': 274}