You are here

function tmgmt_handler_field_tmgmt_wordcount::pre_render in Translation Management Tool 7

Prefetch statistics for all jobs.

Overrides views_handler_field_entity::pre_render

File

views/handlers/tmgmt_handler_field_tmgmt_wordcount.inc, line 13

Class

tmgmt_handler_field_tmgmt_wordcount
Field handler which shows the word count.

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) {
      $tjids[] = $value->tjid;
    }
    tmgmt_job_statistics_load($tjids);
  }
}