-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/language_guessing'
Conflicts: .gitignore composer.json
- Loading branch information
Showing
11 changed files
with
536 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ composer.lock | |
node_modules/ | ||
var/ | ||
package-lock.json | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
/** | ||
* YAWIK SimpleImport | ||
* | ||
* @filesource | ||
* @license MIT | ||
* @copyright 2013 - 2018 Cross Solution <http://cross-solution.de> | ||
*/ | ||
|
||
/** */ | ||
namespace SimpleImport\Controller; | ||
|
||
use Jobs\Entity\Status; | ||
use SimpleImport\Queue\GuessLanguageJob; | ||
use Zend\Console\ColorInterface; | ||
use Zend\Mvc\Console\Controller\AbstractConsoleController; | ||
|
||
/** | ||
* Update crawler configuration or displays crawler information. | ||
* | ||
* @author Mathias Gelhausen <[email protected]> | ||
*/ | ||
class GuessLanguageConsoleController extends AbstractConsoleController | ||
{ | ||
|
||
private $repository; | ||
|
||
public static function getConsoleUsage() | ||
{ | ||
return [ | ||
'simpleimport guess-language [--limit]' => 'Find jobs without language set and pushes a guess-language job into the queue for each.', | ||
['--limit=INT', 'Maximum number of jobs to fetch. 0 means fetch all.'], | ||
'' | ||
]; | ||
} | ||
|
||
public function __construct(\Jobs\Repository\Job $repository) | ||
{ | ||
$this->repository = $repository; | ||
} | ||
|
||
/** | ||
* | ||
* @return string|null | ||
*/ | ||
public function indexAction() | ||
{ | ||
$qb = $this->repository->createQueryBuilder(); | ||
$qb->field('status.name')->in([ | ||
Status::ACTIVE, Status::WAITING_FOR_APPROVAL, Status::CREATED | ||
]); | ||
$qb->addOr( | ||
$qb->expr()->field('language')->exists(false), | ||
$qb->expr()->field('language')->equals('') | ||
); | ||
$qb->limit(10); | ||
|
||
$query = $qb->getQueryArray(); | ||
$jobs = $qb->getQuery()->execute(); | ||
|
||
if (!count($jobs)) { echo "Nothing to do. No jobs without language found.\n\n"; return; } | ||
|
||
$queue = $this->queue('simpleimport'); | ||
foreach ($jobs as $job) { | ||
$queue->push(GuessLanguageJob::class, ['jobId' => $job->getId()]); | ||
printf('Pushed job %s in the queue.' . PHP_EOL, $job->getId()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/Factory/Controller/GuessLanguageConsoleControllerFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
/** | ||
* YAWIK-SimpleImport | ||
* | ||
* @filesource | ||
* @license MIT | ||
* @copyright 2013 - 2019 Cross Solution <http://cross-solution.de> | ||
*/ | ||
|
||
/** */ | ||
namespace SimpleImport\Factory\Controller; | ||
|
||
use SimpleImport\Controller\GuessLanguageConsoleController; | ||
use Interop\Container\ContainerInterface; | ||
use Zend\ServiceManager\Factory\FactoryInterface; | ||
|
||
/** | ||
* Factory for \SimpleImport\Controller\GuessLanguageConsoleController | ||
* | ||
* @author Mathias Gelhausen <[email protected]> | ||
* @todo write test | ||
*/ | ||
class GuessLanguageConsoleControllerFactory implements FactoryInterface | ||
{ | ||
|
||
public function __invoke(ContainerInterface $container, $requestedName, array $options = null) | ||
{ | ||
return new GuessLanguageConsoleController( | ||
$container->get('repositories')->get('Jobs') | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.