You are here

function hosting_get_new_tasks in Hosting 7.3

Same name and namespace in other branches
  1. 7.4 task/hosting_task.module \hosting_get_new_tasks()

Retrieve a list of outstanding, queued, tasks.

Parameters

int $limit: The maximum number of tasks to return.

null $rid: The NID of the referenced Node to filter by.

null $task_type: The task type to filter by.

Return value

array An associative array containing task nodes, indexed by node id.

4 calls to hosting_get_new_tasks()
drush_hosting_queued in queued/hosting_queued.drush.inc
Drush command to execute hosting tasks.
hosting_QUEUE_TYPE_queue in ./hosting.api.php
Process the specified queue.
hosting_tasks_queue in task/hosting_task.module
Process the hosting task queue.
_hosting_get_new_tasks in task/hosting_task.module
Retrieve a list of outstanding, queued, tasks.

File

task/hosting_task.module, line 1465
Web server node type is defined here.

Code

function hosting_get_new_tasks($limit = 20, $rid = NULL, $task_type = NULL) {
  $return = array();
  $query = db_select('hosting_task', 't');
  $query
    ->innerJoin('node', 'n', 't.vid = n.vid');
  $query
    ->fields('t', array(
    'nid',
  ))
    ->condition('t.task_status', HOSTING_TASK_QUEUED)
    ->orderBy('n.changed')
    ->orderBy('n.nid')
    ->groupBy('t.rid')
    ->range(0, $limit)
    ->addTag('hosting_get_new_tasks');
  if ($rid) {
    $query
      ->condition('t.rid', $rid);
  }
  if ($task_type) {
    $query
      ->condition('t.task_type', $task_type);
  }
  foreach ($query
    ->execute() as $node) {
    $return[$node->nid] = node_load($node->nid);
  }
  return $return;
}