完善 任务调度
This commit is contained in:
parent
80053c35aa
commit
db9b20c49b
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Console;
|
namespace App\Console;
|
||||||
|
|
||||||
|
use App\Jobs\ClearTasks;
|
||||||
use App\Jobs\Remote;
|
use App\Jobs\Remote;
|
||||||
use App\Jobs\HostCost;
|
use App\Jobs\HostCost;
|
||||||
use App\Jobs\UserSave;
|
use App\Jobs\UserSave;
|
||||||
@ -27,6 +28,9 @@ protected function schedule(Schedule $schedule)
|
|||||||
$schedule->job(new Remote\PushHost())->everyMinute()->onOneServer();
|
$schedule->job(new Remote\PushHost())->everyMinute()->onOneServer();
|
||||||
$schedule->job(new Remote\PushWorkOrder())->everyMinute()->onOneServer();
|
$schedule->job(new Remote\PushWorkOrder())->everyMinute()->onOneServer();
|
||||||
|
|
||||||
|
$schedule->job(new ClearTasks())->weekly();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
40
app/Jobs/ClearTasks.php
Normal file
40
app/Jobs/ClearTasks.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\Models\User\Task;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class ClearTasks implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
|
||||||
|
// 删除所有状态不为 pending 的任务
|
||||||
|
Task::where('status', '!=', 'pending')->delete();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -63,5 +63,12 @@ protected static function boot()
|
|||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// updateing
|
||||||
|
static::updating(function ($model) {
|
||||||
|
if ($model->progress == 100) {
|
||||||
|
$model->status = 'done';
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user