Ejemplo n.º 1
0
 protected static function getReportHeaders($report)
 {
     $cacheKey = FileSystemCache::generateCacheKey($report, 'report_headers');
     //check if report data is cached and newer than when the report file was created
     //the url parameter ?nocache will bypass this and not use cache
     $data = false;
     if (!isset($_REQUEST['nocache'])) {
         $data = FileSystemCache::retrieve($cacheKey, filemtime(Report::getFileLocation($report)));
     }
     //report data not cached, need to parse it
     if ($data === false) {
         $temp = new Report($report);
         $data = $temp->options;
         $data['report'] = $report;
         $data['url'] = self::$request->base . '/report/html/?report=' . $report;
         $data['is_dir'] = false;
         $data['Id'] = str_replace(array('_', '-', '/', ' ', '.'), array('', '', '_', '-', '_'), trim($report, '/'));
         if (!isset($data['Name'])) {
             $data['Name'] = ucwords(str_replace(array('_', '-'), ' ', basename($report)));
         }
         //store parsed report in cache
         FileSystemCache::store($cacheKey, $data);
     }
     return $data;
 }
Ejemplo n.º 2
0
 public function run()
 {
     if ($this->has_run) {
         return true;
     }
     //at this point, all the headers are parsed and we haven't run the report yet
     foreach ($this->headers as $header) {
         $classname = $header . 'Header';
         $classname::afterParse($this);
     }
     //record how long it takes to run the report
     $start = microtime(true);
     if ($this->is_ready && !$this->async) {
         //if the report is cached
         if ($options = $this->retrieveFromCache()) {
             $this->options = $options;
             $this->options['FromCache'] = true;
         } else {
             $this->_runReport();
             $this->prepareDataSets();
             $this->storeInCache();
         }
         //add this to the list of recently run reports
         $recently_run_key = FileSystemCache::generateCacheKey('recently_run');
         $recently_run = FileSystemCache::retrieve($recently_run_key);
         if ($recently_run === false) {
             $recently_run = array();
         }
         array_unshift($recently_run, $this->report);
         if (count($recently_run) > 200) {
             $recently_run = array_slice($recently_run, 0, 200);
         }
         FileSystemCache::store($recently_run_key, $recently_run);
     }
     //call the beforeRender callback for each header
     foreach ($this->headers as $header) {
         $classname = $header . 'Header';
         $classname::beforeRender($this);
     }
     $this->options['Time'] = round(microtime(true) - $start, 5);
     if ($this->is_ready && !$this->async && !isset($this->options['FromCache'])) {
         //get current report times for this report
         $report_times = FileSystemCache::retrieve($this->getReportTimesCacheKey());
         if (!$report_times) {
             $report_times = array();
         }
         //only keep the last 10 times for each report
         //this keeps the timing data up to date and relevant
         if (count($report_times) > 10) {
             array_shift($report_times);
         }
         //store report times
         $report_times[] = $this->options['Time'];
         FileSystemCache::store($this->getReportTimesCacheKey(), $report_times);
     }
     $this->has_run = true;
 }
Ejemplo n.º 3
0
<?php

require_once 'vendor/autoload.php';
FileSystemCache::$cacheDir = __DIR__ . '/data/';
$console = new ConsoleKit\Console();
$console->addCommand('oat\\deploymentsTools\\AddCommand');
$console->addCommand('oat\\deploymentsTools\\CleanStackCommand');
$console->addCommand('oat\\deploymentsTools\\DebugCommand');
$console->addCommand('oat\\deploymentsTools\\ExecCommand');
$console->run();
 function keyProvider()
 {
     return array(array(FileSystemCache::generateCacheKey('mykey')), array(FileSystemCache::generateCacheKey('mykey', 'test')), array(FileSystemCache::generateCacheKey('mykey', 'test/test')));
 }