<commit_before><?php


namespace h4cc\HHVMProgressBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class PackageUpdateCommand extends ContainerAwareCommand
{
    private $output;

    protected function configure()
    {
        $this
            ->setName('h4cc:hhvm:package:update')
            ->setDescription('Updates the index')
            ->addOption('number-of-packages', 'p', InputOption::VALUE_OPTIONAL, 'Number of Packages to update. "0" to disable.', 200);
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->output = $output;
        $this->input = $input;

        $this->updatePackagesFromPackagistFeed();
        $this->updatePackagesAtRandom();

    }

    protected function updatePackagesFromPackagistFeed()
    {
        $feeds = $this->getContainer()->get('h4cc_hhvm_progress.feeds.packagist');

        $names = $feeds->getRecentPackageNames();

        $this->output->writeln('Updating Packages from Feed: '.count($names));
        $this->updatedPackagesByNames($names);
    }

    protected function updatePackagesAtRandom()
    {
        $local = false;

        if($local) {
            // Packages for testing all three possible hhvm status.<commit_msg>Added a flag '--local' to command 'h4cc:hhvm:package:update'.<commit_after><?php


namespace h4cc\HHVMProgressBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class PackageUpdateCommand extends ContainerAwareCommand
{
    private $output;

    protected function configure()
    {
        $this
            ->setName('h4cc:hhvm:package:update')
            ->setDescription('Updates the index')
            ->addOption('number-of-packages', 'p', InputOption::VALUE_OPTIONAL, 'Number of Packages to update. "0" to disable.', 200)
            ->addOption('local', null, InputOption::VALUE_NONE, 'Only test a fixed list of local packages');
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->output = $output;
        $this->input = $input;

        $this->local = $this->input->getOption('local');

        if(!$this->local) {
            $this->updatePackagesFromPackagistFeed();
        }

        $this->updatePackagesAtRandom();
    }

    protected function updatePackagesFromPackagistFeed()
    {
        $feeds = $this->getContainer()->get('h4cc_hhvm_progress.feeds.packagist');

        $names = $feeds->getRecentPackageNames();

        $this->output->writeln('Updating Packages from Feed: '.count($names));
        $this->updatedPackagesByNames($names);
    }

    protected function updatePackagesAtRandom()
    {
        if($this->local) {
            // Packages for testing all three possible hhvm status.
{'fraction_non_alphanumeric': 0.12214932833489535, 'fraction_numerical': 0.004686035613870665, 'mean_word_length': 3.3328822733423547, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, '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': '935493', 'n_tokens_mistral': 917, 'n_tokens_neox': 890, 'n_words': 173}