Exemple #1
0
 public function topValue(array $params)
 {
     $data = KillModel::find()->sort(array("totalISKValue" => -1))->limit(12);
     $items = array();
     foreach ($data as $item) {
         $items[] = $item;
     }
     return $this->render("top/iskvalue.html", array("data" => $items));
 }
 public function victims(array $parameters)
 {
     $term = $_GET['term'];
     // at least 4 characters here or that will get quite slow
     if (strlen($term) < 4) {
         echo json_encode(array());
         return;
     }
     $result = \Kingboard\Model\Kill::find(array('victim.characterName' => new \MongoRegex('/^' . $term . '.*/i')), array('victim.characterName' => 1))->limit(50);
     $names = array();
     foreach ($result as $res) {
         $names[$res['victim']['characterName']] = true;
     }
     $names = array_keys($names);
     echo json_encode($names);
 }
Exemple #3
0
 private static function findKills(BattleSettings $battleSetting)
 {
     return \Kingboard\Model\Kill::find(array("killTime" => array('$gt' => $battleSetting->startdate, '$lt' => $battleSetting->enddate), "location.solarSystem" => $battleSetting->system, '$or' => array(array("involvedCharacters" => array('$in' => array_merge(array_keys($battleSetting->positives), array((int) $battleSetting->ownerCorporation)))), array("involvedCorporations" => array('$in' => array_merge(array_keys($battleSetting->positives), array((int) $battleSetting->ownerCorporation)))), array("involvedAlliances" => array('$in' => array_merge(array_keys($battleSetting->positives), array((int) $battleSetting->ownerCorporation)))), array("involvedFactions" => array('$in' => array_merge(array_keys($battleSetting->positives), array((int) $battleSetting->ownerCorporation)))))), array("killID" => 1, "solarSystemID" => 1, "killTime" => 1, "moonID" => 1, "victim" => 1, "location" => 1));
 }
Exemple #4
0
 public function index(array $params)
 {
     $context = array();
     if (!isset($params['date'])) {
         $context["date"] = date("Y-m-d");
     } else {
         $context["date"] = $params['date'];
     }
     // get previous day
     $dt = new DateTime($context['date']);
     $context["previousDate"] = date("Y-m-d", $dt->sub(new \DateInterval("P1D"))->getTimestamp());
     $dt = new DateTime($context['date']);
     $ts = $dt->add(new \DateInterval("P1D"))->getTimestamp();
     if ($ts < time()) {
         $context["nextDate"] = date("Y-m-d", $ts);
     } else {
         $context["nextDate"] = date("Y-m-d");
     }
     if (!isset($params['page']) || empty($params['page'])) {
         $page = 1;
     } else {
         $page = (int) $params['page'];
     }
     // reset date
     $dt = new DateTime($context['date']);
     $mdt = new MongoDate($dt->getTimestamp());
     if ($this->_context['ownerID']) {
         $stats = KillsByDayByEntity::findOne($dt->getTimestamp(), $this->_context['ownerID']);
     } else {
         $stats = KillsByDay::findOne($mdt);
     }
     $context['stats'] = $stats['value'];
     $paginator = new Paginator($page, $context['stats']['total']);
     $context['page'] = $paginator->getNavArray();
     // reset date
     $dt = new DateTime($context['date']);
     if ($this->_context['ownerID']) {
         switch ($this->_context['ownerType']) {
             case "alliance":
                 $involvedType = "involvedAlliances";
                 break;
             case "faction":
                 $involvedType = "involvedFactions";
                 break;
             case "corp":
             case "corporation":
                 $involvedType = "involvedCorporations";
                 break;
             case "char":
             case "character":
             case "pilot":
                 $involvedType = "involvedCharacters";
                 break;
             default:
                 throw new \Exception("Configuration has set unknown ownerType!");
                 return;
         }
         $kills = KillModel::find(array('$and' => array(array("killTime" => array('$gt' => new MongoDate($dt->getTimestamp()))), array("killTime" => array('$lt' => new MongoDate($dt->add(new \DateInterval("P1D"))->getTimestamp()))), array($involvedType => $this->_context['ownerID']))))->hint(array("killTime" => 1))->sort(array("killTime" => -1))->skip($paginator->getSkip())->limit(10);
     } else {
         $kills = KillModel::find(array('$and' => array(array("killTime" => array('$gt' => new MongoDate($dt->getTimestamp()))), array("killTime" => array('$lt' => new MongoDate($dt->add(new \DateInterval("P1D"))->getTimestamp()))))))->hint(array("killTime" => 1))->sort(array("killTime" => -1))->skip($paginator->getSkip())->limit(10);
     }
     $context['kills'] = $kills;
     $context['action'] = "/day/" . $context['date'];
     $dt = new DateTime($context['date']);
     $criteria = array('$and' => array(array("startdate" => array('$gt' => new MongoDate($dt->getTimestamp() - 1))), array("startdate" => array('$lt' => new MongoDate($dt->add(new \DateInterval("P1D"))->getTimestamp())))));
     if ($this->_context['ownerID']) {
         $criteria['$or'] = array(array("ownerCharacter" => $this->_context['ownerID']), array("ownerCorporation" => $this->_context['ownerID']), array("ownerAlliance" => $this->_context['ownerID']), array("ownerFaction" => $this->_context['ownerID']));
     }
     $battles = BattleSettings::find($criteria);
     // resolve collection to avoid count() of doom
     $context["battles"] = array();
     foreach ($battles as $battle) {
         $context["battles"][] = $battle->toArray();
     }
     $this->render("date/daily.html", $context);
 }
Exemple #5
0
 /**
  * get kills for the criteria this list obeys
  * @param int $skip
  * @param int $killsPerPage
  * @return \King23\Mongo\MongoResult
  */
 public function getKills($skip, $killsPerPage)
 {
     return \Kingboard\Model\Kill::find($this->criteria)->sort(array('killTime' => -1))->skip($skip)->limit($killsPerPage);
 }