You are here

function tmgmt_handler_field_tmgmt_progress::pre_render in Translation Management Tool 7

Prefetch statistics for all jobs.

Overrides views_handler_field_entity::pre_render

1 call to tmgmt_handler_field_tmgmt_progress::pre_render()
tmgmt_local_task_handler_field_progress::pre_render in translators/tmgmt_local/views/handlers/tmgmt_local_task_handler_field_progress.inc
Prefetch statistics for all jobs.
1 method overrides tmgmt_handler_field_tmgmt_progress::pre_render()
tmgmt_local_task_handler_field_progress::pre_render in translators/tmgmt_local/views/handlers/tmgmt_local_task_handler_field_progress.inc
Prefetch statistics for all jobs.

File

views/handlers/tmgmt_handler_field_tmgmt_progress.inc, line 13

Class

tmgmt_handler_field_tmgmt_progress
Field handler which shows the progressbar.

Code

function pre_render(&$values) {
  parent::pre_render($values);

  // In case of jobs, pre-fetch the statistics in a single query and add them
  // to the static cache.
  if ($this->entity_type == 'tmgmt_job') {
    $tjids = array();
    foreach ($values as $value) {

      // Do not load statistics for aborted jobs.
      if ($value->tmgmt_job_state == TMGMT_JOB_STATE_ABORTED) {
        continue;
      }
      $tjids[] = $value->tjid;
    }
    tmgmt_job_statistics_load($tjids);
  }
}