job stuff
This commit is contained in:
@@ -41,7 +41,7 @@ class CommandHelper {
|
||||
}
|
||||
|
||||
public function CleanJobStatusTable() {
|
||||
DB::table('schedule_jobs')->where('system_time', '<', Carbon::now()->subMonths(6))->delete();
|
||||
DB::table('schedule_jobs')->where('system_time', '<', Carbon::now()->subMonths(3))->delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
42
app/Jobs/Library/JobHelper.php
Normal file
42
app/Jobs/Library/JobHelper.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Jobs\Library;
|
||||
|
||||
//Inertnal Libraries
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use App\Models\Jos\JobStatus;
|
||||
|
||||
class JobHelper {
|
||||
private $job_name;
|
||||
private $complete;
|
||||
private $system_time;
|
||||
|
||||
protected $jobStatus;
|
||||
|
||||
public function __construct($name) {
|
||||
$this->job_name = $name;
|
||||
$this->complete = false;
|
||||
$this->system_time = Carbon::now();
|
||||
}
|
||||
|
||||
public function SetStartStatus() {
|
||||
$this->jobStatus = new JobStatus;
|
||||
$this->jobStatus->job_name = $this->job_name;
|
||||
$this->jobStatus->complete = $this->complete;
|
||||
$this->jobStatus->system_time = $this->system_time;
|
||||
|
||||
$job->save();
|
||||
}
|
||||
|
||||
public function SetStopStatus() {
|
||||
$this->jobStatus::update([
|
||||
'complete' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function CleeanJobStatusTable() {
|
||||
DB::table('job_statuses')->where('system_time', '<', Carbon::now()->subMonths(3))->delete();
|
||||
}
|
||||
}
|
||||
@@ -57,15 +57,15 @@ class ProcessWalletJournalJob implements ShouldQueue
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$status = new JobHelper('Process Wallet Journal');
|
||||
$status->SetStartStatus();
|
||||
|
||||
//Declare the class variable we need
|
||||
$finance = new FinanceHelper();
|
||||
|
||||
$finance->GetWalletJournalPage($this->division, $this->charId, $this->page);
|
||||
|
||||
$status = new JobStatus;
|
||||
$status->job_name = 'Process Wallet Journal';
|
||||
$status->complete = true;
|
||||
$status->save();
|
||||
$status->SetStopStatus();
|
||||
|
||||
//After the job is completed, delete the job
|
||||
$this->delete();
|
||||
|
||||
@@ -53,15 +53,15 @@ class ProcessWalletTransactionJob implements ShouldQueue
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$status = new JobHelper('Process Wallet Transaction');
|
||||
$status->SetStartStatus();
|
||||
|
||||
//Declare the class variables
|
||||
$finance = new FinanceHelper();
|
||||
|
||||
$finance->GetWalletTransaction($this->division, $this->charId);
|
||||
|
||||
$status = new JobStatus;
|
||||
$status->job_name = 'Process Wallet Transaction';
|
||||
$status->complete = true;
|
||||
$status->save();
|
||||
$status->SetStopStatus();
|
||||
|
||||
//After the job is completed, delete the job
|
||||
$this->delete();
|
||||
|
||||
@@ -69,6 +69,9 @@ class SendEveMailJob implements ShouldQueue
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$status = new JobHelper('Send EveMail');
|
||||
$status->SetStartStatus();
|
||||
|
||||
//Retrieve the token for main character to send mails from
|
||||
$token = EsiToken::where(['character_id'=> 93738489])->get();
|
||||
|
||||
@@ -100,10 +103,7 @@ class SendEveMailJob implements ShouldQueue
|
||||
return null;
|
||||
}
|
||||
|
||||
$status = new JobStatus;
|
||||
$status->job_name = 'Send Eve Mail';
|
||||
$status->complete = true;
|
||||
$status->save();
|
||||
$status->SetStopStatus();
|
||||
|
||||
$this->delete();
|
||||
}
|
||||
|
||||
@@ -20,5 +20,6 @@ class JobStatus extends Model
|
||||
protected $fillable = [
|
||||
'job_name',
|
||||
'complete',
|
||||
'system_time',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ class CreateJobStatusTable extends Migration
|
||||
$table->increments('id');
|
||||
$table->string('job_name');
|
||||
$table->boolean('complete');
|
||||
$table->datetime('system_time');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user