Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementCancelWorkflow.php b/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementCancelWorkflow.php
index 7b80787204..2220e945b1 100644
--- a/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementCancelWorkflow.php
+++ b/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementCancelWorkflow.php
@@ -1,52 +1,64 @@
<?php
final class PhabricatorWorkerManagementCancelWorkflow
extends PhabricatorWorkerManagementWorkflow {
protected function didConstruct() {
$this
->setName('cancel')
- ->setExamples('**cancel** --id __id__')
+ ->setExamples('**cancel** __selectors__')
->setSynopsis(
pht(
'Cancel selected tasks. The work these tasks represent will never '.
'be performed.'))
->setArguments($this->getTaskSelectionArguments());
}
public function execute(PhutilArgumentParser $args) {
- $console = PhutilConsole::getConsole();
$tasks = $this->loadTasks($args);
+ if (!$tasks) {
+ $this->logWarn(
+ pht('NO TASKS'),
+ pht('No tasks selected to cancel.'));
+
+ return 0;
+ }
+
+ $cancel_count = 0;
foreach ($tasks as $task) {
$can_cancel = !$task->isArchived();
if (!$can_cancel) {
- $console->writeOut(
- "**<bg:yellow> %s </bg>** %s\n",
+ $this->logWarn(
pht('ARCHIVED'),
pht(
'%s is already archived, and can not be cancelled.',
$this->describeTask($task)));
continue;
}
// Forcibly break the lease if one exists, so we can archive the
// task.
- $task->setLeaseOwner(null);
- $task->setLeaseExpires(PhabricatorTime::getNow());
- $task->archiveTask(
- PhabricatorWorkerArchiveTask::RESULT_CANCELLED,
- 0);
-
- $console->writeOut(
- "**<bg:green> %s </bg>** %s\n",
+ $task
+ ->setLeaseOwner(null)
+ ->setLeaseExpires(PhabricatorTime::getNow());
+
+ $task->archiveTask(PhabricatorWorkerArchiveTask::RESULT_CANCELLED, 0);
+
+ $this->logInfo(
pht('CANCELLED'),
pht(
'%s was cancelled.',
$this->describeTask($task)));
+
+ $cancel_count++;
}
+ $this->logOkay(
+ pht('DONE'),
+ pht('Cancelled %s task(s).', new PhutilNumber($cancel_count)));
+
return 0;
}
}
diff --git a/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementExecuteWorkflow.php b/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementExecuteWorkflow.php
index f3c6be520a..e255b7c963 100644
--- a/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementExecuteWorkflow.php
+++ b/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementExecuteWorkflow.php
@@ -1,104 +1,114 @@
<?php
final class PhabricatorWorkerManagementExecuteWorkflow
extends PhabricatorWorkerManagementWorkflow {
protected function didConstruct() {
$this
->setName('execute')
- ->setExamples('**execute** --id __id__')
+ ->setExamples('**execute** __selectors__')
->setSynopsis(
pht(
'Execute a task explicitly. This command ignores leases, is '.
'dangerous, and may cause work to be performed twice.'))
->setArguments(
array_merge(
array(
array(
'name' => 'retry',
'help' => pht('Retry archived tasks.'),
),
array(
'name' => 'repeat',
'help' => pht('Repeat archived, successful tasks.'),
),
),
$this->getTaskSelectionArguments()));
}
public function execute(PhutilArgumentParser $args) {
- $console = PhutilConsole::getConsole();
- $tasks = $this->loadTasks($args);
-
$is_retry = $args->getArg('retry');
$is_repeat = $args->getArg('repeat');
+ $tasks = $this->loadTasks($args);
+ if (!$tasks) {
+ $this->logWarn(
+ pht('NO TASKS'),
+ pht('No tasks selected to execute.'));
+
+ return 0;
+ }
+
+ $execute_count = 0;
foreach ($tasks as $task) {
$can_execute = !$task->isArchived();
if (!$can_execute) {
if (!$is_retry) {
- $console->writeOut(
- "**<bg:yellow> %s </bg>** %s\n",
+ $this->logWarn(
pht('ARCHIVED'),
pht(
'%s is already archived, and will not be executed. '.
'Use "--retry" to execute archived tasks.',
$this->describeTask($task)));
continue;
}
$result_success = PhabricatorWorkerArchiveTask::RESULT_SUCCESS;
if ($task->getResult() == $result_success) {
if (!$is_repeat) {
- $console->writeOut(
- "**<bg:yellow> %s </bg>** %s\n",
+ $this->logWarn(
pht('SUCCEEDED'),
pht(
'%s has already succeeded, and will not be retried. '.
'Use "--repeat" to repeat successful tasks.',
$this->describeTask($task)));
continue;
}
}
- echo tsprintf(
- "**<bg:yellow> %s </bg>** %s\n",
- pht('ARCHIVED'),
+ $this->logInfo(
+ pht('UNARCHIVING'),
pht(
'Unarchiving %s.',
$this->describeTask($task)));
$task = $task->unarchiveTask();
}
// NOTE: This ignores leases, maybe it should respect them without
// a parameter like --force?
- $task->setLeaseOwner(null);
- $task->setLeaseExpires(PhabricatorTime::getNow());
- $task->save();
+ $task
+ ->setLeaseOwner(null)
+ ->setLeaseExpires(PhabricatorTime::getNow())
+ ->save();
$task_data = id(new PhabricatorWorkerTaskData())->loadOneWhere(
'id = %d',
$task->getDataID());
$task->setData($task_data->getData());
- echo tsprintf(
- "%s\n",
+ $this->logInfo(
+ pht('EXECUTE'),
pht(
- 'Executing task %d (%s)...',
- $task->getID(),
- $task->getTaskClass()));
+ 'Executing %s...',
+ $this->describeTask($task)));
$task = $task->executeTask();
- $ex = $task->getExecutionException();
+ $ex = $task->getExecutionException();
if ($ex) {
throw $ex;
}
+
+ $execute_count++;
}
+ $this->logOkay(
+ pht('DONE'),
+ pht('Executed %s task(s).', new PhutilNumber($execute_count)));
+
return 0;
}
}
diff --git a/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementFreeWorkflow.php b/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementFreeWorkflow.php
index 1ee958be6e..4531ac14d7 100644
--- a/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementFreeWorkflow.php
+++ b/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementFreeWorkflow.php
@@ -1,58 +1,70 @@
<?php
final class PhabricatorWorkerManagementFreeWorkflow
extends PhabricatorWorkerManagementWorkflow {
protected function didConstruct() {
$this
->setName('free')
- ->setExamples('**free** --id __id__')
+ ->setExamples('**free** __selectors__')
->setSynopsis(
pht(
'Free leases on selected tasks. If the daemon holding the lease is '.
'still working on the task, this may cause the task to execute '.
'twice.'))
->setArguments($this->getTaskSelectionArguments());
}
public function execute(PhutilArgumentParser $args) {
- $console = PhutilConsole::getConsole();
$tasks = $this->loadTasks($args);
+ if (!$tasks) {
+ $this->logWarn(
+ pht('NO TASKS'),
+ pht('No tasks selected to free leases on.'));
+
+ return 0;
+ }
+
+ $free_count = 0;
foreach ($tasks as $task) {
if ($task->isArchived()) {
- $console->writeOut(
- "**<bg:yellow> %s </bg>** %s\n",
+ $this->logWarn(
pht('ARCHIVED'),
pht(
'%s is archived; archived tasks do not have leases.',
$this->describeTask($task)));
continue;
}
if ($task->getLeaseOwner() === null) {
- $console->writeOut(
- "**<bg:yellow> %s </bg>** %s\n",
+ $this->logWarn(
pht('FREE'),
pht(
'%s has no active lease.',
$this->describeTask($task)));
continue;
}
- $task->setLeaseOwner(null);
- $task->setLeaseExpires(PhabricatorTime::getNow());
- $task->save();
+ $task
+ ->setLeaseOwner(null)
+ ->setLeaseExpires(PhabricatorTime::getNow())
+ ->save();
- $console->writeOut(
- "**<bg:green> %s </bg>** %s\n",
+ $this->logInfo(
pht('LEASE FREED'),
pht(
'%s was freed from its lease.',
$this->describeTask($task)));
+
+ $free_count++;
}
+ $this->logOkay(
+ pht('DONE'),
+ pht('Freed %s task lease(s).', new PhutilNumber($free_count)));
+
return 0;
}
}
diff --git a/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementRetryWorkflow.php b/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementRetryWorkflow.php
index 538a70add8..5f61285193 100644
--- a/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementRetryWorkflow.php
+++ b/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementRetryWorkflow.php
@@ -1,69 +1,80 @@
<?php
final class PhabricatorWorkerManagementRetryWorkflow
extends PhabricatorWorkerManagementWorkflow {
protected function didConstruct() {
$this
->setName('retry')
- ->setExamples('**retry** --id __id__')
+ ->setExamples('**retry** __selectors__')
->setSynopsis(
pht(
'Retry selected tasks which previously failed permanently or '.
'were cancelled. Only archived tasks can be retried.'))
->setArguments(
array_merge(
array(
array(
'name' => 'repeat',
'help' => pht(
'Repeat tasks which already completed successfully.'),
),
),
$this->getTaskSelectionArguments()));
}
public function execute(PhutilArgumentParser $args) {
- $console = PhutilConsole::getConsole();
+ $is_repeat = $args->getArg('repeat');
+
$tasks = $this->loadTasks($args);
+ if (!$tasks) {
+ $this->logWarn(
+ pht('NO TASKS'),
+ pht('No tasks selected to retry.'));
- $is_repeat = $args->getArg('repeat');
+ return 0;
+ }
+
+ $retry_count = 0;
foreach ($tasks as $task) {
if (!$task->isArchived()) {
- $console->writeOut(
- "**<bg:yellow> %s </bg>** %s\n",
+ $this->logWarn(
pht('ACTIVE'),
pht(
'%s is already in the active task queue.',
$this->describeTask($task)));
continue;
}
$result_success = PhabricatorWorkerArchiveTask::RESULT_SUCCESS;
if ($task->getResult() == $result_success) {
if (!$is_repeat) {
- $console->writeOut(
- "**<bg:yellow> %s </bg>** %s\n",
+ $this->logWarn(
pht('SUCCEEDED'),
pht(
'%s has already succeeded, and will not be repeated. '.
'Use "--repeat" to repeat successful tasks.',
$this->describeTask($task)));
continue;
}
}
$task->unarchiveTask();
- $console->writeOut(
- "**<bg:green> %s </bg>** %s\n",
+ $this->logInfo(
pht('QUEUED'),
pht(
'%s was queued for retry.',
$this->describeTask($task)));
+
+ $retry_count++;
}
+ $this->logOkay(
+ pht('DONE'),
+ pht('Queued %s task(s) for retry.', new PhutilNumber($retry_count)));
+
return 0;
}
}
diff --git a/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementWorkflow.php b/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementWorkflow.php
index 113f3348d5..29721ca236 100644
--- a/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementWorkflow.php
+++ b/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementWorkflow.php
@@ -1,120 +1,310 @@
<?php
abstract class PhabricatorWorkerManagementWorkflow
extends PhabricatorManagementWorkflow {
protected function getTaskSelectionArguments() {
return array(
array(
'name' => 'id',
'param' => 'id',
'repeat' => true,
'help' => pht('Select one or more tasks by ID.'),
),
array(
'name' => 'class',
'param' => 'name',
- 'help' => pht('Select all tasks of a given class.'),
+ 'help' => pht('Select tasks of a given class.'),
),
array(
'name' => 'min-failure-count',
'param' => 'int',
- 'help' => pht('Limit to tasks with at least this many failures.'),
+ 'help' => pht('Select tasks with a minimum failure count.'),
+ ),
+ array(
+ 'name' => 'max-failure-count',
+ 'param' => 'int',
+ 'help' => pht('Select tasks with a maximum failure count.'),
),
array(
'name' => 'active',
- 'help' => pht('Select all active tasks.'),
+ 'help' => pht('Select active tasks.'),
+ ),
+ array(
+ 'name' => 'archived',
+ 'help' => pht('Select archived tasks.'),
+ ),
+ array(
+ 'name' => 'container',
+ 'param' => 'name',
+ 'help' => pht(
+ 'Select tasks with the given container or containers.'),
+ 'repeat' => true,
+ ),
+ array(
+ 'name' => 'object',
+ 'param' => 'name',
+ 'repeat' => true,
+ 'help' => pht(
+ 'Select tasks affecting the given object or objects.'),
+ ),
+ array(
+ 'name' => 'min-priority',
+ 'param' => 'int',
+ 'help' => pht('Select tasks with a minimum priority.'),
+ ),
+ array(
+ 'name' => 'max-priority',
+ 'param' => 'int',
+ 'help' => pht('Select tasks with a maximum priority.'),
+ ),
+ array(
+ 'name' => 'limit',
+ 'param' => 'int',
+ 'help' => pht('Limit selection to a maximum number of tasks.'),
),
);
}
protected function loadTasks(PhutilArgumentParser $args) {
$ids = $args->getArg('id');
$class = $args->getArg('class');
- $min_failures = $args->getArg('min-failure-count');
$active = $args->getArg('active');
+ $archived = $args->getArg('archived');
+
+ $container_names = $args->getArg('container');
+ $object_names = $args->getArg('object');
+
+ $min_failures = $args->getArg('min-failure-count');
+ $max_failures = $args->getArg('max-failure-count');
- if (!$ids && !$class && !$min_failures && !$active) {
+ $min_priority = $args->getArg('min-priority');
+ $max_priority = $args->getArg('max-priority');
+
+ $limit = $args->getArg('limit');
+
+ $any_constraints = false;
+ if ($ids) {
+ $any_constraints = true;
+ }
+
+ if ($class) {
+ $any_constraints = true;
+ }
+
+ if ($active || $archived) {
+ $any_constraints = true;
+ if ($active && $archived) {
+ throw new PhutilArgumentUsageException(
+ pht(
+ 'You can not specify both "--active" and "--archived" tasks: '.
+ 'no tasks can match both constraints.'));
+ }
+ }
+
+ if ($container_names) {
+ $any_constraints = true;
+ $container_phids = $this->loadObjectPHIDsFromArguments($container_names);
+ } else {
+ $container_phids = array();
+ }
+
+ if ($object_names) {
+ $any_constraints = true;
+ $object_phids = $this->loadObjectPHIDsFromArguments($object_names);
+ } else {
+ $object_phids = array();
+ }
+
+ if (($min_failures !== null) || ($max_failures !== null)) {
+ $any_constraints = true;
+ if (($min_failures !== null) && ($max_failures !== null)) {
+ if ($min_failures > $max_failures) {
+ throw new PhutilArgumentUsageException(
+ pht(
+ 'Specified "--min-failures" must not be larger than '.
+ 'specified "--max-failures".'));
+ }
+ }
+ }
+
+ if (($min_priority !== null) || ($max_priority !== null)) {
+ $any_constraints = true;
+ if (($min_priority !== null) && ($max_priority !== null)) {
+ if ($min_priority > $max_priority) {
+ throw new PhutilArgumentUsageException(
+ pht(
+ 'Specified "--min-priority" may not be larger than '.
+ 'specified "--max-priority".'));
+ }
+ }
+ }
+
+ if (!$any_constraints) {
throw new PhutilArgumentUsageException(
pht(
- 'Use "--id", "--class", "--active", and/or "--min-failure-count" '.
- 'to select tasks.'));
+ 'Use constraint flags (like "--id" or "--class") to select which '.
+ 'tasks to affect. Use "--help" for a list of supported constraint '.
+ 'flags.'));
+ }
+
+ if ($limit !== null) {
+ $limit = (int)$limit;
+ if ($limit <= 0) {
+ throw new PhutilArgumentUsageException(
+ pht(
+ 'Specified "--limit" must be a positive integer.'));
+ }
}
$active_query = new PhabricatorWorkerActiveTaskQuery();
$archive_query = new PhabricatorWorkerArchiveTaskQuery();
if ($ids) {
$active_query = $active_query->withIDs($ids);
$archive_query = $archive_query->withIDs($ids);
}
if ($class) {
$class_array = array($class);
$active_query = $active_query->withClassNames($class_array);
$archive_query = $archive_query->withClassNames($class_array);
}
if ($min_failures) {
- $active_query = $active_query->withFailureCountBetween(
- $min_failures, null);
- $archive_query = $archive_query->withFailureCountBetween(
- $min_failures, null);
+ $active_query->withFailureCountBetween($min_failures, $max_failures);
+ $archive_query->withFailureCountBetween($min_failures, $max_failures);
+ }
+
+ if ($container_phids) {
+ $active_query->withContainerPHIDs($container_phids);
+ $archive_query->withContainerPHIDs($container_phids);
+ }
+
+ if ($object_phids) {
+ $active_query->withObjectPHIDs($object_phids);
+ $archive_query->withObjectPHIDs($object_phids);
+ }
+
+ if ($min_priority || $max_priority) {
+ $active_query->withPriorityBetween($min_priority, $max_priority);
+ $archive_query->withPriorityBetween($min_priority, $max_priority);
+ }
+
+ if ($limit) {
+ $active_query->setLimit($limit);
+ $archive_query->setLimit($limit);
}
- $active_tasks = $active_query->execute();
+ if ($archived) {
+ $active_tasks = array();
+ } else {
+ $active_tasks = $active_query->execute();
+ }
if ($active) {
$archive_tasks = array();
} else {
$archive_tasks = $archive_query->execute();
}
$tasks =
mpull($active_tasks, null, 'getID') +
mpull($archive_tasks, null, 'getID');
+ if ($limit) {
+ $tasks = array_slice($tasks, 0, $limit, $preserve_keys = true);
+ }
+
+
if ($ids) {
foreach ($ids as $id) {
if (empty($tasks[$id])) {
throw new PhutilArgumentUsageException(
- pht('No task exists with id "%s"!', $id));
+ pht('No task with ID "%s" matches the constraints!', $id));
}
}
}
- if ($class && $min_failures) {
- if (!$tasks) {
- throw new PhutilArgumentUsageException(
- pht('No task exists with class "%s" and at least %d failures!',
- $class,
- $min_failures));
- }
- } else if ($class) {
- if (!$tasks) {
- throw new PhutilArgumentUsageException(
- pht('No task exists with class "%s"!', $class));
- }
- } else if ($min_failures) {
- if (!$tasks) {
- throw new PhutilArgumentUsageException(
- pht('No tasks exist with at least %d failures!', $min_failures));
- }
- }
+
+ // We check that IDs are valid, but for all other constraints it is
+ // acceptable to select no tasks to act upon.
// When we lock tasks properly, this gets populated as a side effect. Just
// fake it when doing manual CLI stuff. This makes sure CLI yields have
// their expires times set properly.
foreach ($tasks as $task) {
if ($task instanceof PhabricatorWorkerActiveTask) {
$task->setServerTime(PhabricatorTime::getNow());
}
}
+ // If the user specified one or more "--id" flags, process the tasks in
+ // the given order. Otherwise, process them in FIFO order so the sequence
+ // is somewhat consistent with natural execution order.
+
+ // NOTE: When "--limit" is used, we end up selecting the newest tasks
+ // first. At time of writing, there's no way to order the queries
+ // correctly, so just accept it as reasonable behavior.
+
+ if ($ids) {
+ $tasks = array_select_keys($tasks, $ids);
+ } else {
+ $tasks = msort($tasks, 'getID');
+ }
+
return $tasks;
}
protected function describeTask(PhabricatorWorkerTask $task) {
return pht('Task %d (%s)', $task->getID(), $task->getTaskClass());
}
+ private function loadObjectPHIDsFromArguments(array $names) {
+ $viewer = $this->getViewer();
+
+ $seen_names = array();
+ foreach ($names as $name) {
+ if (isset($seen_names[$name])) {
+ throw new PhutilArgumentUsageException(
+ pht(
+ 'Object "%s" is specified more than once. Specify only unique '.
+ 'objects.',
+ $name));
+ }
+ $seen_names[$name] = true;
+ }
+
+ $object_query = id(new PhabricatorObjectQuery())
+ ->setViewer($viewer)
+ ->withNames($names);
+
+ $object_query->execute();
+
+ $name_map = $object_query->getNamedResults();
+ $phid_map = array();
+ foreach ($names as $name) {
+ if (!isset($name_map[$name])) {
+ throw new PhutilArgumentUsageException(
+ pht(
+ 'No object with name "%s" could be loaded.',
+ $name));
+ }
+
+ $phid = $name_map[$name]->getPHID();
+
+ if (isset($phid_map[$phid])) {
+ throw new PhutilArgumentUsageException(
+ pht(
+ 'Names "%s" and "%s" identify the same object. Specify only '.
+ 'unique objects.',
+ $name,
+ $phid_map[$phid]));
+ }
+
+ $phid_map[$phid] = $name;
+ }
+
+ return array_keys($phid_map);
+ }
+
}
diff --git a/src/infrastructure/daemon/workers/query/PhabricatorWorkerTaskQuery.php b/src/infrastructure/daemon/workers/query/PhabricatorWorkerTaskQuery.php
index 3797de50f9..2446dc62cc 100644
--- a/src/infrastructure/daemon/workers/query/PhabricatorWorkerTaskQuery.php
+++ b/src/infrastructure/daemon/workers/query/PhabricatorWorkerTaskQuery.php
@@ -1,128 +1,163 @@
<?php
abstract class PhabricatorWorkerTaskQuery
extends PhabricatorQuery {
private $ids;
private $dateModifiedSince;
private $dateCreatedBefore;
private $objectPHIDs;
+ private $containerPHIDs;
private $classNames;
private $limit;
private $minFailureCount;
private $maxFailureCount;
+ private $minPriority;
+ private $maxPriority;
public function withIDs(array $ids) {
$this->ids = $ids;
return $this;
}
public function withDateModifiedSince($timestamp) {
$this->dateModifiedSince = $timestamp;
return $this;
}
public function withDateCreatedBefore($timestamp) {
$this->dateCreatedBefore = $timestamp;
return $this;
}
public function withObjectPHIDs(array $phids) {
$this->objectPHIDs = $phids;
return $this;
}
+ public function withContainerPHIDs(array $phids) {
+ $this->containerPHIDs = $phids;
+ return $this;
+ }
+
public function withClassNames(array $names) {
$this->classNames = $names;
return $this;
}
public function withFailureCountBetween($min, $max) {
$this->minFailureCount = $min;
$this->maxFailureCount = $max;
return $this;
}
+ public function withPriorityBetween($min, $max) {
+ $this->minPriority = $min;
+ $this->maxPriority = $max;
+ return $this;
+ }
+
public function setLimit($limit) {
$this->limit = $limit;
return $this;
}
protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array();
if ($this->ids !== null) {
$where[] = qsprintf(
$conn,
'id in (%Ld)',
$this->ids);
}
if ($this->objectPHIDs !== null) {
$where[] = qsprintf(
$conn,
'objectPHID IN (%Ls)',
$this->objectPHIDs);
}
+ if ($this->containerPHIDs !== null) {
+ $where[] = qsprintf(
+ $conn,
+ 'containerPHID IN (%Ls)',
+ $this->containerPHIDs);
+ }
+
if ($this->dateModifiedSince !== null) {
$where[] = qsprintf(
$conn,
'dateModified > %d',
$this->dateModifiedSince);
}
if ($this->dateCreatedBefore !== null) {
$where[] = qsprintf(
$conn,
'dateCreated < %d',
$this->dateCreatedBefore);
}
if ($this->classNames !== null) {
$where[] = qsprintf(
$conn,
'taskClass IN (%Ls)',
$this->classNames);
}
if ($this->minFailureCount !== null) {
$where[] = qsprintf(
$conn,
'failureCount >= %d',
$this->minFailureCount);
}
if ($this->maxFailureCount !== null) {
$where[] = qsprintf(
$conn,
'failureCount <= %d',
$this->maxFailureCount);
}
+ if ($this->minPriority !== null) {
+ $where[] = qsprintf(
+ $conn,
+ 'priority >= %d',
+ $this->minPriority);
+ }
+
+ if ($this->maxPriority !== null) {
+ $where[] = qsprintf(
+ $conn,
+ 'priority <= %d',
+ $this->maxPriority);
+ }
+
return $this->formatWhereClause($conn, $where);
}
protected function buildOrderClause(AphrontDatabaseConnection $conn) {
// NOTE: The garbage collector executes this query with a date constraint,
// and the query is inefficient if we don't use the same key for ordering.
// See T9808 for discussion.
if ($this->dateCreatedBefore) {
return qsprintf($conn, 'ORDER BY dateCreated DESC, id DESC');
} else if ($this->dateModifiedSince) {
return qsprintf($conn, 'ORDER BY dateModified DESC, id DESC');
} else {
return qsprintf($conn, 'ORDER BY id DESC');
}
}
protected function buildLimitClause(AphrontDatabaseConnection $conn) {
if ($this->limit) {
return qsprintf($conn, 'LIMIT %d', $this->limit);
} else {
return qsprintf($conn, '');
}
}
}

File Metadata

Mime Type
text/x-diff
Expires
Sun, Nov 24, 7:22 AM (1 d, 15 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
991
Default Alt Text
(26 KB)

Event Timeline