update 1.0.8.0
Commits for version update
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use App\Model\MailJob\Condition;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
@@ -14,6 +15,9 @@ class Kernel extends ConsoleKernel
|
||||
*/
|
||||
protected $commands = [
|
||||
'App\Console\Commands\Inspire',
|
||||
'App\Console\Commands\SendReport',
|
||||
'App\Console\Commands\CloseWork',
|
||||
'App\Console\Commands\TicketFetch',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -25,12 +29,97 @@ class Kernel extends ConsoleKernel
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
$schedule->command('inspire')
|
||||
->hourly();
|
||||
if (env('DB_INSTALL') == 1) {
|
||||
$queue = $this->getCurrentQueue();
|
||||
$schedule->command('queue:listen '.$queue, ['--tries' => 1])->everyMinute()->withoutOverlapping();
|
||||
$this->execute($schedule, 'fetching');
|
||||
$this->execute($schedule, 'notification');
|
||||
$this->execute($schedule, 'work');
|
||||
$this->execute($schedule, 'followup');
|
||||
$this->execute($schedule, 'message');
|
||||
loging('cron', 'executed successfully', 'info');
|
||||
}
|
||||
}
|
||||
|
||||
$schedule->call(function () {
|
||||
$user = new User();
|
||||
$user->save();
|
||||
})->everyFiveMinutes();
|
||||
public function execute($schedule, $task)
|
||||
{
|
||||
$condition = new Condition();
|
||||
$command = $condition->getConditionValue($task);
|
||||
switch ($task) {
|
||||
case 'fetching':
|
||||
$this->getCondition($schedule->command('ticket:fetch'), $command);
|
||||
break;
|
||||
case 'notification':
|
||||
$this->getCondition($schedule->command('report:send'), $command);
|
||||
break;
|
||||
case 'work':
|
||||
$this->getCondition($schedule->command('ticket:close'), $command);
|
||||
break;
|
||||
case 'followup':
|
||||
$this->getCondition($schedule->command('users:followup'), $command);
|
||||
break;
|
||||
case 'message':
|
||||
$this->getCondition($schedule->command('message:send'), $command);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCondition($schedule, $command)
|
||||
{
|
||||
$condition = $command['condition'];
|
||||
$at = $command['at'];
|
||||
switch ($condition) {
|
||||
case 'everyMinute':
|
||||
$schedule->everyMinute()->withoutOverlapping();
|
||||
break;
|
||||
case 'everyFiveMinutes':
|
||||
$schedule->everyFiveMinutes()->withoutOverlapping();
|
||||
break;
|
||||
case 'everyTenMinutes':
|
||||
$schedule->everyTenMinutes()->withoutOverlapping();
|
||||
break;
|
||||
case 'everyThirtyMinutes':
|
||||
$schedule->everyThirtyMinutes()->withoutOverlapping();
|
||||
break;
|
||||
case 'hourly':
|
||||
$schedule->hourly()->withoutOverlapping();
|
||||
break;
|
||||
case 'daily':
|
||||
$schedule->daily()->withoutOverlapping();
|
||||
break;
|
||||
case 'dailyAt':
|
||||
$this->getConditionWithOption($schedule, $condition, $at);
|
||||
break;
|
||||
case 'weekly':
|
||||
$schedule->weekly()->withoutOverlapping();
|
||||
break;
|
||||
case 'monthly':
|
||||
$schedule->monthly()->withoutOverlapping();
|
||||
break;
|
||||
case 'yearly':
|
||||
$schedule->yearly()->withoutOverlapping();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function getConditionWithOption($schedule, $command, $at)
|
||||
{
|
||||
switch ($command) {
|
||||
case 'dailyAt':
|
||||
$schedule->dailyAt($at)->withoutOverlapping();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCurrentQueue()
|
||||
{
|
||||
$queue = 'database';
|
||||
$services = new \App\Model\MailJob\QueueService();
|
||||
$current = $services->where('status', 1)->first();
|
||||
if ($current) {
|
||||
$queue = $current->short_name;
|
||||
}
|
||||
|
||||
return $queue;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user