You are here

function background_batch_overview_page in Background Process 7

Same name and namespace in other branches
  1. 6 background_batch/background_batch.pages.inc \background_batch_overview_page()
  2. 7.2 background_batch/background_batch.pages.inc \background_batch_overview_page()

Overview of current and recent batch jobs.

1 string reference to 'background_batch_overview_page'
background_batch_menu in background_batch/background_batch.module
Implements hook_menu().

File

background_batch/background_batch.pages.inc, line 41
Pages for background batch.

Code

function background_batch_overview_page() {
  $data = array();
  $bids = db_select('batch', 'b')
    ->fields('b', array(
    'bid',
  ))
    ->orderBy('b.bid', 'ASC')
    ->execute()
    ->fetchAllKeyed(0, 0);
  foreach ($bids as $bid) {
    $progress = progress_get_progress('_background_batch:' . $bid);
    if (!$progress) {
      $progress = (object) array(
        'start' => 0,
        'end' => 0,
        'progress' => 0,
        'message' => t('N/A'),
      );
    }
    $eta = progress_estimate_completion($progress);
    $data[] = array(
      $progress->end ? $bid : l($bid, 'batch', array(
        'query' => array(
          'op' => 'start',
          'id' => $bid,
        ),
      )),
      sprintf("%.2f%%", $progress->progress * 100),
      $progress->message,
      $progress->start ? format_date((int) $progress->start, 'small') : t('N/A'),
      $progress->end ? format_date((int) $progress->end, 'small') : ($eta ? format_date((int) $eta, 'small') : t('N/A')),
    );
  }
  $header = array(
    'Batch ID',
    'Progress',
    'Message',
    'Started',
    'Finished/ETA',
  );
  return theme('table', array(
    'header' => $header,
    'rows' => $data,
  ));
}