public function getLogs($identifier, $category)
 {
     $identifier = Parser::slugifyIdentifier($identifier);
     $filename = sprintf("%s%s%s.log", $this->logsPath, $this->logsPrefix, $identifier);
     if (file_exists($filename)) {
         $logs = json_decode(file_get_contents($filename), true);
     } else {
         $logs = array();
     }
     $logs = isset($logs[$identifier]) ? $logs[$identifier] : array();
     return Parser::get($logs, $category);
 }
Example #2
0
 /**
  * @param string $command
  * @param string $category
  * @param array $logs
  *
  * @return Highchart
  */
 public static function get($command, $category, array $logs)
 {
     $series = array(array("name" => sprintf("%s - %s statistics", $command, ucfirst($category)), "data" => array_values($logs)));
     $ob = new Highchart();
     $ob->chart->renderTo('linechart');
     // The #id of the div where to render the chart
     $ob->title->text('Chart Title');
     $ob->xAxis->title(array('text' => "Date and time"));
     $ob->xAxis->categories(array_keys($logs));
     $ob->yAxis->title(array('text' => sprintf("%s (in %s)", ucfirst($category), Parser::getCategoryUnit($category))));
     $ob->series($series);
     return $ob;
 }
 /**
  * @param $identifier
  *
  * @return array
  */
 public function getLogs($identifier, $category)
 {
     $this->collection = $this->client->selectCollection($this->db, Parser::slugifyIdentifier($identifier));
     $logs = iterator_to_array($this->collection->find());
     return Parser::get($logs, $category);
 }