Пример #1
0
 /**
  * Export stats.
  * @param $groupId
  * @param $type
  * @param $saveTo
  * @return bool
  * @throws \Exception
  */
 public function export($groupId, $type, $saveTo)
 {
     if (!$this->actionParser->groupExists($groupId)) {
         throw new \Exception('Group ID does not exist: ' . $groupId);
     }
     if ($type != 'csv') {
         throw new \Exception('Unknown export type: ' . $type);
     }
     $actions = $this->actionParser->parseGroup($groupId);
     $fullRows = $this->actionParser->getFullRows($actions);
     $fullRows = $this->filterRows($fullRows);
     $this->exportToCSV($fullRows, $saveTo);
     $this->display->outputMessage('Export saved to: ' . $saveTo);
     return true;
 }
Пример #2
0
 /**
  * Display stats.
  * @return bool
  */
 public function showStatsList()
 {
     $sql = "SELECT groupid, MIN(timeadded) AS mintime, MAX(timeadded) AS maxtime, COUNT(id) AS numactions\n                FROM dbtrack_actions\n                GROUP BY groupid\n                ORDER BY MIN(timeadded)";
     $results = $this->dbms->getResults($sql);
     if (empty($results)) {
         $this->display->outputMessage('No stats found.');
         return true;
     }
     $this->display->setHeader(array('Group', 'From', 'To', 'Actions'));
     $this->display->setPadding(array(5, 19, 19, 10));
     $this->display->showHeader();
     foreach ($results as $result) {
         $line = array($result->groupid, date('d/m/Y H:i:s', $result->mintime), date('d/m/Y H:i:s', $result->maxtime), $result->numactions);
         $this->display->showLine($line);
     }
     return true;
 }