예제 #1
0
 /**
  * update statistics
  * @param array $options
  * @return void
  */
 public function update_stats(array $options)
 {
     $log = Registry::getInstance()->getLogger();
     $log->info('start updating stats');
     $log->info('updating kills by Shiptype');
     // stats table of how often all ships have been killed
     KillsByShip::mapReduce();
     $log->info('update of KillsByShip stats completed');
     $log->info('updating pilot loss stats');
     LossesByShipByPilot::mapReduce();
     $log->info('update of pilot loss stats completed');
     $log->info('updating pilot kill stats');
     KillsByShipByPilot::mapReduce();
     $log->info('update of pilot kill stats completed');
     $log->info('updating corporation loss stats');
     LossesByShipByCorporation::mapReduce();
     $log->info('update of corporation loss stats completed');
     $log->info('updating corporation kill stats');
     KillsByShipByCorporation::mapReduce();
     $log->info('update of corporation kill stats completed');
     $log->info('updating alliance loss stats');
     LossesByShipByAlliance::mapReduce();
     $log->info('update of alliance loss stats completed');
     $log->info('updating alliance kill stats');
     KillsByShipByAlliance::mapReduce();
     $log->info('update of alliance kill stats completed');
     $log->info('updating faction loss stats');
     LossesByShipByFaction::mapReduce();
     $log->info('update of faction loss stats completed');
     $log->info('updating faction kill stats');
     KillsByShipByFaction::mapReduce();
     $log->info('update of faction kill stats completed');
     $log->info('updating name lists for search');
     NameSearch::mapReduce();
     $log->info("name list updated");
     $log->info('updating daily stats');
     KillsByDay::mapReduce();
     $log->info("daily stats updated");
     $log->info('updating daily stats by entity');
     KillsByDayByEntity::mapReduce();
     $log->info("daily stats by entity updated");
 }
예제 #2
0
 /**
  * @param string $ownerType
  * @param string $ownerID
  */
 public function __construct($ownerType, $ownerID)
 {
     $this->ownerType = $ownerType;
     $this->ownerID = $ownerID;
     switch ($this->ownerType) {
         case "alliance":
             $killstats = \Kingboard\Model\MapReduce\KillsByShipByAlliance::getInstanceByAllianceId((int) $this->ownerID);
             $lossstats = \Kingboard\Model\MapReduce\LossesByShipByAlliance::getInstanceByAllianceId((int) $this->ownerID);
             $criteria = array("involvedAlliances" => (int) $this->ownerID);
             break;
         case "faction":
             $killstats = \Kingboard\Model\MapReduce\KillsByShipByFaction::getInstanceByFactionId((int) $this->ownerID);
             $lossstats = \Kingboard\Model\MapReduce\LossesByShipByFaction::getInstanceByFactionId((int) $this->ownerID);
             $criteria = array("involvedFactions" => (int) $this->ownerID);
             break;
         case "corp":
         case "corporation":
             $killstats = \Kingboard\Model\MapReduce\KillsByShipByCorporation::getInstanceByCorporationId((int) $this->ownerID);
             $lossstats = \Kingboard\Model\MapReduce\LossesByShipByCorporation::getInstanceByCorporationId((int) $this->ownerID);
             $criteria = array("involvedCorporations" => (int) $this->ownerID);
             break;
         case "char":
         case "character":
         case "pilot":
             $killstats = \Kingboard\Model\MapReduce\KillsByShipByPilot::getInstanceByPilotId((int) $this->ownerID);
             $lossstats = \Kingboard\Model\MapReduce\LossesByShipByPilot::getInstanceByPilotId((int) $this->ownerID);
             /*$criteria = array('$or' => array(
                   array('attackers.characterID' => (int) $this->ownerID),
                   array('victim.characterID' => (int) $this->ownerID)
               ));*/
             $criteria = array("involvedCharacters" => (int) $this->ownerID);
             break;
         default:
             // its not a known type of anything, so we dont need to set anything here.
             // but can return
             return;
     }
     $totalstats = array();
     $count = 0;
     if (isset($killstats['value']['ship'])) {
         foreach ($killstats['value']['ship'] as $type => $value) {
             if (!isset($totalstats[$type])) {
                 $totalstats[$type] = array('kills' => 0, 'losses' => 0);
             }
             $totalstats[$type]['kills'] = $value;
             $count += $value;
         }
     }
     if (isset($lossstats['value']['ship'])) {
         foreach ($lossstats['value']['ship'] as $type => $value) {
             if (!isset($totalstats[$type])) {
                 $totalstats[$type] = array('kills' => 0, 'losses' => 0);
             }
             $totalstats[$type]['losses'] = $value;
             $count += $value;
         }
     }
     ksort($totalstats);
     $this->killstats = $killstats;
     $this->lossstats = $lossstats;
     $this->totalstats = $totalstats;
     $this->criteria = $criteria;
     $this->count = $count;
 }