diff -r 0e57c730bb18 -r 54f204bceb28 Command/QueryWikipediaCommand.php --- a/Command/QueryWikipediaCommand.php Fri Nov 25 18:55:42 2011 +0100 +++ b/Command/QueryWikipediaCommand.php Sun Nov 27 22:36:21 2011 +0100 @@ -11,6 +11,7 @@ use IRI\Bundle\WikiTagBundle\Utils\WikiTagUtils; +use IRI\Bundle\WikiTagBundle\Model\Tag; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -41,7 +42,8 @@ ->setName('wikitag:query-wikipedia') ->setDescription('Query wikipedia for tags.') ->addOption("force","f",InputOption::VALUE_NONE, "Force remove tags") - ->addOption("all","a",InputOption::VALUE_NONE, "Force remove tags") + ->addOption("all","a",InputOption::VALUE_NONE, "all") + ->addOption("redirection",null,InputOption::VALUE_NONE, "Treat redirections") ->addOption("random","r",InputOption::VALUE_NONE, "randomize query on tags") ->addOption("site","S",InputOption::VALUE_OPTIONAL, "the url for the wikipedia site", "http://fr.wikipedia.org/w/api.php") ->addOption("limit","l",InputOption::VALUE_OPTIONAL, "number of tag to process", -1) @@ -54,6 +56,7 @@ $force = $input->getOption('force'); $all = $input->getOption('all'); $random = $input->getOption('random'); + $redirection = $input->getOption('redirection'); $site = $input->getOption('site'); $limit = intval($input->getOption('limit')); $start = intval($input->getOption('start')); @@ -66,7 +69,12 @@ if(!$all) { - $qb->where($qb->expr()->isNull("t.urlStatus")); + if($redirection) { + $qb->where($qb->expr()->andx($qb->expr()->eq("t.urlStatus",Tag::$TAG_URL_STATUS_DICT['redirection']), $qb->expr()->isNull("t.alternativeLabel"))); + } + else { + $qb->where($qb->expr()->isNull("t.urlStatus")); + } } if($start > 0) @@ -86,6 +94,12 @@ $count = count($qb_count->getQuery()->getScalarResult()); $doctrine->getEntityManager()->clear(); + if($count === 0) + { + $output->writeln("No tag to process, exit."); + return; + } + if(! $force && $input->isInteractive()) { $dialog = $this->getHelper('dialog');