/**
  * Export in CSV the datas builded from SQL queries
  * @return String $content the CSV content
  */
 public function exportCSV()
 {
     $this->stats_formatter->clearContent();
     $this->stats_formatter->addLine(array_values($this->title));
     foreach ($this->datas as $value) {
         $this->stats_formatter->addLine(array_values($value));
     }
     return $this->stats_formatter->getCsvContent();
 }
 public function itClearsContent()
 {
     $data_line = array('Data', 'Data', 'Data');
     $statistics_formatter = new Statistics_Formatter('', '', ',');
     $statistics_formatter->addHeader('Title');
     $statistics_formatter->addLine($data_line);
     $statistics_formatter->addEmptyLine();
     $statistics_formatter->clearContent();
     $this->assertEqual($statistics_formatter->getCsvContent(), '');
 }
Example #3
0
 /**
  * Obtain statistics about backend format for CSV export
  *
  * @param Statistics_Formatter $formatter instance of statistics formatter class
  *
  * @return String
  */
 public function getBackendStatistics(Statistics_Formatter $formatter)
 {
     $dao = $this->getDao();
     $formatter->clearContent();
     $formatter->addEmptyLine();
     $formatter->addHeader('Git');
     $gitShellIndex[] = $GLOBALS['Language']->getText('plugin_statistics', 'scm_month');
     $gitShell[] = "Git shell created repositories";
     $gitShellActiveIndex[] = $GLOBALS['Language']->getText('plugin_statistics', 'scm_month');
     $gitShellActive[] = "Git shell created repositories (still active)";
     $gitoliteIndex[] = $GLOBALS['Language']->getText('plugin_statistics', 'scm_month');
     $gitolite[] = "Gitolite created repositories";
     $gitoliteActiveIndex[] = $GLOBALS['Language']->getText('plugin_statistics', 'scm_month');
     $gitoliteActive[] = "Gitolite created repositories (still active)";
     $this->fillBackendStatisticsByType($formatter, 'gitshell', $gitShellIndex, $gitShell, false);
     $this->fillBackendStatisticsByType($formatter, 'gitshell', $gitShellActiveIndex, $gitShellActive, true);
     $this->fillBackendStatisticsByType($formatter, 'gitolite', $gitoliteIndex, $gitolite, false);
     $this->fillBackendStatisticsByType($formatter, 'gitolite', $gitoliteActiveIndex, $gitoliteActive, true);
     $this->retrieveLoggedPushesStatistics($formatter);
     $content = $formatter->getCsvContent();
     $formatter->clearContent();
     return $content;
 }
Example #4
0
 /**
  * Obtain statistics about backend format for CSV export
  *
  * @param Statistics_Formatter $formatter instance of statistics formatter class
  *
  * @return String
  */
 public function getBackendStatistics(Statistics_Formatter $formatter)
 {
     $dao = $this->getDao();
     $formatter->clearContent();
     $formatter->addEmptyLine();
     $formatter->addHeader('Git');
     $gitShellIndex[] = $GLOBALS['Language']->getText('plugin_statistics', 'scm_month');
     $gitShell[] = "Git shell";
     $gitoliteIndex[] = $GLOBALS['Language']->getText('plugin_statistics', 'scm_month');
     $gitolite[] = "Gitolite";
     $dar = $dao->getBackendStatistics('gitshell', $formatter->startDate, $formatter->endDate, $formatter->groupId);
     if ($dar && !$dar->isError() && $dar->rowCount() > 0) {
         foreach ($dar as $row) {
             $gitShellIndex[] = $row['month'] . " " . $row['year'];
             $gitShell[] = intval($row['count']);
         }
         $formatter->addLine($gitShellIndex);
         $formatter->addLine($gitShell);
     }
     $dar = $dao->getBackendStatistics('gitolite', $formatter->startDate, $formatter->endDate, $formatter->groupId);
     if ($dar && !$dar->isError() && $dar->rowCount() > 0) {
         foreach ($dar as $row) {
             $gitoliteIndex[] = $row['month'] . " " . $row['year'];
             $gitolite[] = intval($row['count']);
         }
         $formatter->addLine($gitoliteIndex);
         $formatter->addLine($gitolite);
     }
     $this->retrieveLoggedPushesStatistics($formatter);
     $content = $formatter->getCsvContent();
     $formatter->clearContent();
     return $content;
 }