Permalink
Browse files

try to more quickly check the state of a li task job before preparing…

… from crawl
  • Loading branch information...
webignition committed Mar 20, 2015
1 parent 6de9eb7 commit 141537b0a97c14ef0dc1b46012d09eee7cf7c266
@@ -45,14 +45,14 @@ public function completeAction($canonical_url, $task_type, $parameter_hash) {
return $this->sendFailureResponse();
}
$taskType = $this->getTaskTypeService()->getByName($task_type);
$taskType = $this->getTaskTypeService()->getByName($task_type);
$tasks = $this->getTaskService()->getEquivalentTasks($canonical_url, $taskType, $parameter_hash, $this->getTaskService()->getIncompleteStates());
if (count($tasks) === 0) {
return $this->sendGoneResponse();
}
$endDateTime = new \DateTime($this->getArguments('completeByUrlAndTaskTypeAction')->get('end_date_time'));
$rawOutput = $this->getArguments('completeByUrlAndTaskTypeAction')->get('output');
@@ -89,20 +89,22 @@ public function completeAction($canonical_url, $task_type, $parameter_hash) {
$this->getJobService()->complete($task->getJob());
}
if ($task->getType()->equals($this->getTaskTypeService()->getByName('URL discovery'))) {
if ($task->getType()->equals($urlDiscoveryTaskType)) {
if ($this->getJobService()->isCompleted($task->getJob())) {
$crawlJobContainer = $this->getCrawlJobContainerService()->getForJob($task->getJob());
if ($this->getCrawlJobContainerService()->getEntityRepository()->doesCrawlTaskParentStateMatchState($task, $this->getJobService()->getFailedNoSitemapState())) {
$crawlJobContainer = $this->getCrawlJobContainerService()->getForJob($task->getJob());
foreach ($crawlJobContainer->getParentJob()->getRequestedTaskTypes() as $taskType) {
/* @var $taskType TaskType */
$taskTypeParameterDomainsToIgnoreKey = strtolower(str_replace(' ', '-', $taskType->getName())) . '-domains-to-ignore';
foreach ($crawlJobContainer->getParentJob()->getRequestedTaskTypes() as $taskType) {
/* @var $taskType TaskType */
$taskTypeParameterDomainsToIgnoreKey = strtolower(str_replace(' ', '-', $taskType->getName())) . '-domains-to-ignore';
if ($this->container->hasParameter($taskTypeParameterDomainsToIgnoreKey)) {
$this->getJobPreparationService()->setPredefinedDomainsToIgnore($taskType, $this->container->getParameter($taskTypeParameterDomainsToIgnoreKey));
if ($this->container->hasParameter($taskTypeParameterDomainsToIgnoreKey)) {
$this->getJobPreparationService()->setPredefinedDomainsToIgnore($taskType, $this->container->getParameter($taskTypeParameterDomainsToIgnoreKey));
}
}
}
$this->getJobPreparationService()->prepareFromCrawl($crawlJobContainer);
$this->getJobPreparationService()->prepareFromCrawl($crawlJobContainer);
}
}
$this->getResqueQueueService()->enqueue(
@@ -3,10 +3,29 @@
use Doctrine\ORM\EntityRepository;
use SimplyTestable\ApiBundle\Entity\Job\Job;
use SimplyTestable\ApiBundle\Entity\State;
use SimplyTestable\ApiBundle\Entity\Task\Task;
use SimplyTestable\ApiBundle\Entity\User;
class CrawlJobContainerRepository extends EntityRepository
{
public function doesCrawlTaskParentStateMatchState(Task $task, State $state) {
$queryBuilder = $this->createQueryBuilder('CrawlJobContainer');
$queryBuilder->join('CrawlJobContainer.parentJob', 'ParentJob');
$queryBuilder->join('CrawlJobContainer.crawlJob', 'CrawlJob');
$queryBuilder->join('ParentJob.state', 'State');
$queryBuilder->select('State.name');
$queryBuilder->where('CrawlJob = :CrawlJob');
$queryBuilder->setParameter('CrawlJob', $task->getJob());
$queryBuilder->setMaxResults(1);
$result = $queryBuilder->getQuery()->getResult();
return (count($result) === 0) ? false : $result[0]['name'] == $state->getName();
}
/**
*

0 comments on commit 141537b

Please sign in to comment.