You are here

function drush_forena_report in Forena Reports 7.5

Same name and namespace in other branches
  1. 8 forena.drush.inc \drush_forena_report()
  2. 7.4 forena.drush.inc \drush_forena_report()

Run a report to a fiel.

File

./forena.drush.inc, line 43
forena.drush.inc Implementation of drush command hook.

Code

function drush_forena_report($report_uri, $filename = '') {
  require_once 'forena.common.inc';
  $parms = array();
  $query = '';
  $report_name = $report_uri;
  $m1 = memory_get_usage();
  $t1 = time();
  @(list($report_name, $query) = explode('?', $report_uri));
  if ($query) {
    parse_str($query, $parms);
  }
  if ($filename) {
    drupal_set_message(t('Writing report %s  to %f.', array(
      '%s' => $report_name,
      '%f' => $filename,
    )));
    forena_report($report_name, $parms, FALSE, $filename);
  }
  else {
    drupal_set_message(t('Generating report %s.', array(
      '%s' => $report_name,
    )));
    print forena_report($report_name, $parms, FALSE);
  }
  $t2 = time();
  $m2 = memory_get_usage();
  $p = memory_get_peak_usage();
  $dur = $t2 - $t1;
  $mem = $m2 - $m1;
  drupal_set_message(t('Finished Report ( %s seconds, %b bytes, peak %p)', array(
    '%s' => $dur,
    '%b' => $mem,
    '%p' => $p,
  )));
}