job stuff

This commit is contained in:
2019-05-13 23:18:10 -05:00
parent 79323c2388
commit 98ee6f5206
7 changed files with 57 additions and 13 deletions

View File

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

View 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();
}
}

View File

@@ -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();

View File

@@ -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();

View File

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

View File

@@ -20,5 +20,6 @@ class JobStatus extends Model
protected $fillable = [
'job_name',
'complete',
'system_time',
];
}

View File

@@ -18,6 +18,7 @@ class CreateJobStatusTable extends Migration
$table->increments('id');
$table->string('job_name');
$table->boolean('complete');
$table->datetime('system_time');
$table->timestamps();
});
}