Example #1
0
 public function setGroup($group)
 {
     if (KurogoStats::isValidGroup($group)) {
         $this->group = is_array($group) ? $group : explode(',', $group);
     } else {
         throw new Exception("Invalid group field {$group}");
     }
 }
Example #2
0
 protected function getStatsData($chartData)
 {
     $kurogoOption = new KurogoStatsOption();
     $type = isset($chartData['stattype']) ? $chartData['stattype'] : 'count';
     $kurogoOption->setType($type);
     if ($chartData['service']) {
         $kurogoOption->setService($chartData['service']);
         unset($chartData['service']);
     }
     if ($chartData['start']) {
         $kurogoOption->addFilter('timestamp', 'GTE', $chartData['start']);
     }
     if ($chartData['end']) {
         $kurogoOption->addFilter('timestamp', 'LTE', $chartData['end']);
     }
     if (isset($chartData['sort'])) {
         $kurogoOption->setSortField($chartData['sort']);
     }
     if (isset($chartData['sort_dir'])) {
         $kurogoOption->setSortDir($chartData['sort_dir']);
     }
     if (isset($chartData['group'])) {
         $kurogoOption->setGroup($chartData['group']);
     }
     if (isset($chartData['field'])) {
         $kurogoOption->setField($chartData['field']);
     }
     if (isset($chartData['top'])) {
         $kurogoOption->setLimit($chartData['top']);
     }
     foreach (KurogoStats::validFields() as $field) {
         if (isset($chartData[$field])) {
             $kurogoOption->addFilter($field, 'EQ', $chartData[$field]);
         }
     }
     return KurogoStats::retrieveStats($kurogoOption, $chartData);
 }
 protected function logView($size = null)
 {
     if ($this->logView) {
         KurogoStats::logView('web', $this->configModule, $this->page, $this->logData, $this->logDataLabel, $size);
     }
 }
Example #4
0
 protected function logCommand($size = null)
 {
     KurogoStats::logView('api', $this->configModule, $this->command, $this->logData, $this->logDataLabel, $size);
 }
 protected function initializeForCommand()
 {
     switch ($this->command) {
         case 'migrate':
             $this->migrateData();
             return 0;
             break;
         case 'summary':
             $this->migrateData(true);
             return 0;
             break;
         case 'update':
             KurogoStats::exportStatsData();
             return 0;
             break;
         case 'updateFromShards':
             if ($timestamp = $this->getArg('timestamp')) {
                 KurogoStats::updateSummaryFromShards($timestamp);
                 return 0;
             }
             $this->out('timestamp parameter is required');
             return 10;
             break;
         default:
             $this->invalidCommand();
             break;
     }
 }