diff --git a/app/Jobs/Commands/FetchMoonLedgerJob.php b/app/Jobs/Commands/FetchMoonLedgerJob.php index 6094f71fc..9b308297b 100644 --- a/app/Jobs/Commands/FetchMoonLedgerJob.php +++ b/app/Jobs/Commands/FetchMoonLedgerJob.php @@ -92,6 +92,7 @@ class FetchMoonLedgerJob implements ShouldQueue ])->get(); foreach($observers as $observer) { + //Try to get the ledger data from the esi try { $ledgers = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/{observer_id}/', [ 'corporation_id' => $character->corporation_id, @@ -111,9 +112,31 @@ class FetchMoonLedgerJob implements ShouldQueue $charInfo = $lookup->GetCharacterInfo($ledger->character_id); //Get the corporation info from the lookup helper $corpInfo = $lookup->GetCorporationInfo($charInfo->corporation_id); + //Get the recorded corporation information + $recordedCorpInfo = $lookup->GetCorporationInfo($ledger->recorded_corporation_id); - + $entries[] = [ + 'corporation_id' => $corpInfo->corporation_id, + 'corporation_name' => $corpInfo->name, + 'character_id' => $charInfo->character_id, + 'character_name' => $charInfo->name, + 'observer_id' => $observer->observer_id, + 'observer_name' => $observer->observer_name, + 'type_id' => $ledger->type_id, + 'ore' => $ore, + 'quantity' => $ledger->quantity, + 'recorded_corporation_id' => $ledger->recorded_corporation_id, + 'recorded_corporation_name' => $recordedCorpInfo->name, + 'last_updated' => $ledger->last_updated, + 'created_at' => $ledger->last_updated . ' 23:59:59', + 'updated_at' => $ledger->last_updated . ' 23:59:59', + ]; } + + //Insert or ignore each entry into the database + CorpMoonLedger::insertOrIgnore($entries); + + Log::info('FetchMoonLedgerJob inserted up to ' . count($entries) . 'into the database.'); } } } diff --git a/app/Jobs/Commands/FetchMoonObserversJob.php b/app/Jobs/Commands/FetchMoonObserversJob.php index 5cb494219..7cec75564 100644 --- a/app/Jobs/Commands/FetchMoonObserversJob.php +++ b/app/Jobs/Commands/FetchMoonObserversJob.php @@ -98,7 +98,7 @@ class FetchMoonObserversJob implements ShouldQueue CorpMoonObserver::where([ 'observer_id' => $observer->observer_id, ])->update([ - 'last_updated' => $esi->DecodeDate($observer->last_updated), + 'last_updated' => $observer->last_updated, ]); } } diff --git a/app/Jobs/Commands/MoonRentalInvoiceJob.php b/app/Jobs/Commands/MoonRentalInvoiceVerify.php similarity index 71% rename from app/Jobs/Commands/MoonRentalInvoiceJob.php rename to app/Jobs/Commands/MoonRentalInvoiceVerify.php index d51c7393d..fcb75dd4a 100644 --- a/app/Jobs/Commands/MoonRentalInvoiceJob.php +++ b/app/Jobs/Commands/MoonRentalInvoiceVerify.php @@ -8,22 +8,9 @@ use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; -class MoonRentalInvoiceJob implements ShouldQueue +class MoonRentalInvoiceVerify implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; - /** - * Timeout in seconds - * - * @var int - */ - public $timeout = 3600; - - /** - * Retries - * - * @var int - */ - public $retries = 3; /** * Create a new job instance. diff --git a/app/Jobs/Commands/FetchRentalMoonLedgerJob.php b/app/Jobs/Commands/Not Used/FetchRentalMoonLedgerJob.php similarity index 89% rename from app/Jobs/Commands/FetchRentalMoonLedgerJob.php rename to app/Jobs/Commands/Not Used/FetchRentalMoonLedgerJob.php index 4a7ad6df4..039ce301a 100644 --- a/app/Jobs/Commands/FetchRentalMoonLedgerJob.php +++ b/app/Jobs/Commands/Not Used/FetchRentalMoonLedgerJob.php @@ -85,7 +85,10 @@ class FetchRentalMoonLedgerJob implements ShouldQueue //Foreach observer get the ledger foreach($observers as $observer) { //Get the observer name. - + $observerInfo = Structure::where([ + 'structure_id' => $observer->observer_id, + ])->first(); + try { $ledgers = $esi->invoke('get', '/corporation/{corporation_id}/mining/observers/{observer_id}/', [ 'corporation_id' => $character->corporation_id, @@ -106,18 +109,21 @@ class FetchRentalMoonLedgerJob implements ShouldQueue //Get the corporation information $corpInfo = $lookup->GetCorporationInfo($charInfo->corporation_id); + //Get the recorded corporation information + $recordedCorpInfo = $lookup->GetCorporationInfo($ledger->recorded_corporation_id); + $entries[] = [ - 'corporation_id' => $corpId, - 'corporation_name' => $corpName, + 'corporation_id' => $corpInfo->corporation_id, + 'corporation_name' => $corpInfo->name, 'character_id' => $ledger->character_id, 'character_name' => $charInfo->name, 'observer_id' => $observer->observer_id, - 'observer_name' => $observerName, + 'observer_name' => $observerInfo->name, 'type_id' => $ledger->type_id, 'ore' => $ore, 'quantity' => $ledger->quantity, 'recorded_corporation_id' => $ledger->recorded_corporation_id, - 'recorded_corporation_name' => $recordedCorpName, + 'recorded_corporation_name' => $recordedCorpInfo->name, 'last_updated' => $ledger->last_updated, 'created_at' => $ledger->last_updated . ' 23:59:59', 'updated_at' => $ledger->last_updated . ' 23:59:59', diff --git a/app/Jobs/Commands/FetchRentalMoonObserversJob.php b/app/Jobs/Commands/Not Used/FetchRentalMoonObserversJob.php similarity index 100% rename from app/Jobs/Commands/FetchRentalMoonObserversJob.php rename to app/Jobs/Commands/Not Used/FetchRentalMoonObserversJob.php