Beispiel #1
0
 /**
  * Return the Killmails for a Corporation
  *
  * @param int  $corporation_id
  * @param bool $get
  * @param int  $chunk
  *
  * @return \Illuminate\Pagination\LengthAwarePaginator
  */
 public function getCorporationKillmails(int $corporation_id, bool $get = true, int $chunk = 200)
 {
     $killmails = KillMail::select('*', 'corporation_kill_mails.corporationID as ownerID', 'kill_mail_details.corporationID as victimID')->leftJoin('kill_mail_details', 'corporation_kill_mails.killID', '=', 'kill_mail_details.killID')->leftJoin('invTypes', 'kill_mail_details.shipTypeID', '=', 'invTypes.typeID')->leftJoin('mapDenormalize', 'kill_mail_details.solarSystemID', '=', 'mapDenormalize.itemID')->where('corporation_kill_mails.corporationID', $corporation_id);
     if ($get) {
         return $killmails->orderBy('corporation_kill_mails.killID', 'desc')->paginate($chunk);
     }
     return $killmails;
 }
 /**
  * Return the Killmails for a Corporation
  *
  * @param $corporation_id
  *
  * @return mixed
  */
 public function getCorporationKillmails($corporation_id)
 {
     return KillMail::select('*', 'corporation_kill_mails.corporationID as ownerID', 'kill_mail_details.corporationID as victimID')->leftJoin('kill_mail_details', 'corporation_kill_mails.killID', '=', 'kill_mail_details.killID')->leftJoin('invTypes', 'kill_mail_details.shipTypeID', '=', 'invTypes.typeID')->leftJoin('mapDenormalize', 'kill_mail_details.solarSystemID', '=', 'mapDenormalize.itemID')->where('corporation_kill_mails.corporationID', $corporation_id)->get();
 }
Beispiel #3
0
 /**
  * Run the Update
  *
  * @return mixed|void
  */
 public function call()
 {
     // Killmails is another tricky one to update correctly.
     // Refer to the comment in character/killmails of this
     // project for some background.
     $pheal = $this->setScope('corp')->setCorporationID()->getPheal();
     // Define the first MAX from_id to use when
     // retreiving killmails.
     $from_id = PHP_INT_MAX;
     // This infinite loop needs to be broken out of
     // once we have reached the end of the backwards
     // journal walking. Walking ends when we have
     // either received less rows than asked for, or
     // we have reached a known killID.
     while (true) {
         $result = $pheal->KillMails(['rowCount' => $this->rows_per_call] + ($from_id == PHP_INT_MAX ? [] : ['fromID' => $from_id]));
         foreach ($result->kills as $kill) {
             // Ensure that $from_id is at its lowest
             $from_id = min($kill->killID, $from_id);
             // Check if the killmail is known. If it is,
             // then we can just continue to the next. We
             // are assuming the kill details already is
             // known here.
             if (KillMail::where('corporationID', $this->corporationID)->where('killID', $kill->killID)->first()) {
                 continue;
             }
             // Create the killmail link to this corporation
             KillMail::create(['corporationID' => $this->corporationID, 'killID' => $kill->killID]);
             // With the link complete, we should check if we
             // have the information for this kill recorded.
             // If it is already in the database, then there
             // is simply no need for us to redo all of that
             // work again. Remember, from this point on, we
             // refer to a kill by killID, regardless of the
             // assosiated corporationID
             if (Detail::where('killID', $kill->killID)->first()) {
                 continue;
             }
             // Create the killDetails, attacker and item info
             Detail::create(['killID' => $kill->killID, 'solarSystemID' => $kill->solarSystemID, 'killTime' => $kill->killTime, 'moonID' => $kill->moonID, 'characterID' => $kill->victim->characterID, 'characterName' => $kill->victim->characterName, 'corporationID' => $kill->victim->corporationID, 'corporationName' => $kill->victim->corporationName, 'allianceID' => $kill->victim->allianceID, 'allianceName' => $kill->victim->allianceName, 'factionID' => $kill->victim->factionID, 'factionName' => $kill->victim->factionName, 'damageTaken' => $kill->victim->damageTaken, 'shipTypeID' => $kill->victim->shipTypeID]);
             foreach ($kill->attackers as $attacker) {
                 Attacker::create(['killID' => $kill->killID, 'characterID' => $attacker->characterID, 'characterName' => $attacker->characterName, 'corporationID' => $attacker->corporationID, 'corporationName' => $attacker->corporationName, 'allianceID' => $attacker->allianceID, 'allianceName' => $attacker->allianceName, 'factionID' => $attacker->factionID, 'factionName' => $attacker->factionName, 'securityStatus' => $attacker->securityStatus, 'damageDone' => $attacker->damageDone, 'finalBlow' => $attacker->finalBlow, 'weaponTypeID' => $attacker->weaponTypeID, 'shipTypeID' => $attacker->shipTypeID]);
             }
             foreach ($kill->items as $item) {
                 Item::create(['killID' => $kill->killID, 'typeID' => $item->typeID, 'flag' => $item->flag, 'qtyDropped' => $item->qtyDropped, 'qtyDestroyed' => $item->qtyDestroyed, 'singleton' => $item->singleton]);
             }
         }
         // Foreach kills
         // As previously mentioned, there may be a few
         // conditions where we may decide its time to
         // break out of the infinite loop. This is where
         // we will be doing those checks. The most ob-
         // vious one being that we may have received less
         // than the total amount of rows asked for.
         if (count($result->kills) < $this->rows_per_call) {
             break;
         }
     }
     // while(true)
     return;
 }