You are here

function ws_performance_overview in Web Service Data 7

1 string reference to 'ws_performance_overview'
ws_performance_menu in modules/ws_performance/ws_performance.module
Implements hook_menu().

File

modules/ws_performance/ws_performance.admin.inc, line 42

Code

function ws_performance_overview() {
  $form = array();
  $header = array(
    array(
      'data' => t('WSConfig'),
      'field' => 'wsconfig_name',
    ),
    array(
      'data' => t('Total number of calls'),
      'field' => 'total',
    ),
    array(
      'data' => t('Average result size (bytes)'),
      'field' => 'size',
    ),
    array(
      'data' => t('Average response time (ms)'),
      'field' => 'wait',
    ),
    array(
      'data' => t('Since'),
      'field' => 'run',
    ),
  );
  $results = db_query('SELECT wsconfig_name, COUNT(0) AS total, AVG(size) AS size, AVG(wait) AS wait, MIN(run) AS run FROM {ws_performance} GROUP BY wsconfig_name;');
  $rows = array();
  foreach ($results as $result) {
    $row = array();
    foreach ((array) $result as $key => $data) {
      $row[$key]['data'] = $data;
      $row[$key]['header'] = $key;
      switch ($key) {
        case 'run':
          $row[$key]['data'] = format_date($data);
          break;
        case 'wsconfig_name':
          $row[$key]['data'] = l($data, 'admin/reports/ws_performance/' . $data);
          break;
      }
    }
    $rows[] = $row;
  }
  $form['wsconfig_list'] = array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
  );
  return $form;
}