tweaked some jobs

This commit is contained in:
2021-03-18 19:31:26 +09:00
parent 7aee591a2c
commit 466a1750bd
4 changed files with 76 additions and 54 deletions

View File

@@ -51,7 +51,7 @@ class MiningTaxesDataCleanup extends Command
$task->SetStartStatus();
//Clean up old data
Ledger::where(['updated_at', '<', Carbon::now()->subDays(120)])->delete();
Ledger::where(['updated_at', '<', Carbon::now()->subDays(90)])->delete();
//Set the task as finished
$task->SetStopStatus();

View File

@@ -134,6 +134,18 @@ class MiningTaxesInvoices extends Command
$body .= "<br>";
$body .= "<br>Sincerely,<br>Warped Intentions Leadership<br>";
//Check if the mail body is greater than 2000 characters. If greater than 2,000 characters, then
if(sizeof($body) > 2000) {
$body = "Dear Miner,<br><br>";
$body .= "Total Value of Ore Mined: " . number_format($totalPrice, 2, ".", ",") . " ISK.";
$body .= "<br><br>";
$body .= "Please remit " . number_format($invoiceAmount, 2, ".", ",") . " ISK to Spatial Forces by " . $dateDue . "<br>";
$body .= "Set the reason for transfer as MMT: " . $invoiceId . "<br>";
$body .= "The mining taxes are currently set to " . $numberMiningTax . "%.<br>";
$body .= "<br>";
$body .= "<br>Sincerely,<br>Warped Intentions Leadership<br>";
}
//Mail the invoice to the character if the character is in
//Warped Intentions or Legacy
$subject = 'Warped Intentions Mining Taxes';

View File

@@ -125,40 +125,46 @@ class ProcessSendEveMailJob implements ShouldQueue
switch($errorCode) {
case 400: //Bad Request
$this->release(15);
Log::critical("Bad request has occurred in ProcessSendEveMailJob. Job has been discarded");
return 0;
break;
case 401: //Unauthorized Request
$this->release(15);
Log::critical("Unauthorized request has occurred in ProcessSendEveMailJob at " . Carbon::now()->toDateTimeString() . ".\r\nCancelling the job.");
return 0;
break;
case 403: //Forbidden
$this->release(15);
Log::critical("ProcessSendEveMailJob has incurred a forbidden error. Cancelling the job.");
return 0;
break;
case 420: //Error Limited
Log::warning("Error rate limit occurred in ProcessSendEveMailJob. Restarting job in 120 seconds.");
$this->release(120);
break;
case 500: //Internal Server Error
Log::critical("Internal Server Error for ESI in ProcessSendEveMailJob");
return 0;
Log::critical("Internal Server Error for ESI in ProcessSendEveMailJob. Attempting a restart in 120 seconds.");
$this->release(120);
break;
case 503: //Service Unavailable
Log::critical("Service Unavailabe for ESI in ProcessSendEveMailJob");
$this->release(15);
Log::critical("Service Unavailabe for ESI in ProcessSendEveMailJob. Releasing the job back to the queue in 30 seconds.");
$this->release(30);
break;
case 504: //Gateway Timeout
Log::critical("Gateway timeout in ProcessSendEveMailJob");
$this->release(15);
Log::critical("Gateway timeout in ProcessSendEveMailJob. Releasing the job back to the queue in 30 seconds.");
$this->release(30);
break;
case 520: //Internal Error -- Mostly comes when rate limited hit
$this->release(15);
Log::warning("Rate limit hit for ProcessSendEveMailJob. Releasing the job back to the queue in 30 seconds.");
$this->release(30);
break;
case 201:
$this->SaveSentRecord($this->sender, $this->subject, $this->body, $this->recipient, $this->recipient_type);
$this->delete();
break;
default: //If not an error, then just break out of the switch statement
break;
}
$this->SaveSentRecord($this->sender, $this->subject, $this->body, $this->recipient, $this->recipient_type);
$this->delete();
return 0;
}
/**

View File

@@ -68,6 +68,12 @@ class ProcessMiningTaxesLedgersJob implements ShouldQueue
$mHelper = new MoonCalc;
$config = config('esi');
//Create a starting date for the ledger
$ledgerDate = Carbon::createFromFormat('Y-m-d', $this->ledger->last_updated);
//If the ledger is more than one day old, then process it, otherwise, we don't process it
//or add it to the database as it may still be updating.
if($ledgerDate->lessThan(Carbon::now()->subDay())) {
//Get some of the basic information we need to work with
$charName = $lookup->CharacterIdToName($this->ledger->character_id);
//Get the type name from the ledger ore
@@ -93,12 +99,7 @@ class ProcessMiningTaxesLedgersJob implements ShouldQueue
'quantity' => $this->ledger->quantity,
'last_updated' => $this->ledger->last_updated,
])->update([
'character_id' => $this->ledger->character_id,
'character_name' => $charName,
'observer_id' => $this->observerId,
'last_updated' => $this->ledger->last_updated,
'type_id' => $this->ledger->type_id,
'ore_name' => $typeName,
'quantity' => $this->ledger->quantity,
'amount' => $amount,
]);
@@ -115,4 +116,7 @@ class ProcessMiningTaxesLedgersJob implements ShouldQueue
$ledg->save();
}
}
return 0;
}
}