Example #1
0
 public function nameAlliance(array $params)
 {
     $id = 0;
     if (!empty($params['alliancename'])) {
         foreach (\Kingboard\Model\MapReduce\NameSearch::search($params['alliancename'], 1) as $result) {
             $id = $result->value['id'];
         }
         $this->redirect("/details/alliance/{$id}/");
         return;
     }
     return $this->error("unknown alliance");
 }
Example #2
0
 public function search(array $search)
 {
     $result = array();
     $find = $search["text"];
     if (strlen($find) < 4) {
         echo json_encode(array());
         return;
     }
     foreach (\Kingboard\Model\MapReduce\NameSearch::search($find, 6) as $searchresult) {
         $result[] = $searchresult->_id;
     }
     echo json_encode($result);
     return;
 }
 /**
  * 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");
 }
Example #4
0
 public static function getFactionIdFromName($name)
 {
     $id = 0;
     foreach (\Kingboard\Model\MapReduce\NameSearch::search($name, 1) as $result) {
         $id = $result->value['id'];
     }
     if ($id > 0) {
         return $id;
     } else {
         // find a random kill with characterID $id
         $kill = parent::doFindOne(__CLASS__, array('$or' => array(array('victim.factionName' => $name), array('attackers.factionName' => $name))), array('victim.factionName' => 1, 'attackers.factionName' => 1, 'victim.factionID' => 1, 'attackers.factionID' => 1));
         if ($kill['victim']['factionName'] == $name) {
             return $kill['victim']['factionID'];
         } else {
             foreach ($kill['attackers'] as $attacker) {
                 if ($attacker['factionName'] == $name) {
                     return $attacker['factionID'];
                 }
             }
         }
         return false;
     }
 }
Example #5
0
 public function topLoser(array $params)
 {
     $result = LossesByShipByPilot::find(array("_id" => array('$gt' => 0)))->sort(array("value.total" => -1))->limit(12);
     $data = array();
     foreach ($result as $value) {
         $name = NameSearch::getNameByEveId($value->_id);
         $data[] = array("name" => $name, "kills" => $value);
     }
     $this->render("top/loser.html", array("data" => $data));
 }
Example #6
0
 /**
  * ensure there is an ID placed
  * @param string $id
  * @param string $charname
  * @return int
  * @throws \Exception
  */
 public function ensureEveEntityID($id, $charname)
 {
     $id = (int) $id;
     if ($id == 0) {
         if ($id = NameSearch::getEveIdByName($charname)) {
             return $id;
         }
         if (!empty($charname)) {
             Registry::getInstance()->getLogger()->debug("{$charname} not found, trying to fetch from API");
             $pheal = new Pheal();
             $result = $pheal->eveScope->typeName(array('names' => $charname))->toArray();
             if ((int) $result[0]['characterID'] > 0) {
                 return (int) $result[0]['characterID'];
             }
         }
         Registry::getInstance()->getLogger()->warning("no id found for {$charname}");
         // with an empty charname we have to assume its 0
         return 0;
         //throw new \Exception("No such characterID");
     }
     return $id;
 }