created the job for fetch moon ledger

This commit is contained in:
2020-05-10 18:46:58 -05:00
parent 1d19732eeb
commit b7291a93b7
5 changed files with 37 additions and 21 deletions

View File

@@ -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.');
}
}
}

View File

@@ -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,
]);
}
}

View File

@@ -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.

View File

@@ -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',