Progress Fix Scheduling
This commit is contained in:
parent
425630ad44
commit
e166932809
@ -46,7 +46,7 @@ public function handle(Request $request, Closure $next): Response
|
|||||||
$systemRoutes = [
|
$systemRoutes = [
|
||||||
'Host' => [' fas fa-server', 'host'],
|
'Host' => [' fas fa-server', 'host'],
|
||||||
'Maintenance' => [' fas fa-calendar', 'maintenance'],
|
'Maintenance' => [' fas fa-calendar', 'maintenance'],
|
||||||
'Tasks' => [' fas fa-calendar', 'tasks'],
|
'Tasks' => [' fas fa-list', 'tasks'],
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($systemRoutes as $title => $route_data) {
|
foreach ($systemRoutes as $title => $route_data) {
|
||||||
|
@ -5,12 +5,14 @@
|
|||||||
use App\Models\Maintenance;
|
use App\Models\Maintenance;
|
||||||
use App\Models\MaintenanceHistory;
|
use App\Models\MaintenanceHistory;
|
||||||
use App\Models\MaintenanceTaskHistory;
|
use App\Models\MaintenanceTaskHistory;
|
||||||
|
use Carbon\Carbon;
|
||||||
use Cron\CronExpression;
|
use Cron\CronExpression;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Illuminate\Foundation\Queue\Queueable;
|
use Illuminate\Foundation\Queue\Queueable;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Poliander\Cron\CronExpression as CronCronExpression;
|
||||||
|
|
||||||
class ScheduleNextMaintenance implements ShouldQueue
|
class ScheduleNextMaintenance implements ShouldQueue
|
||||||
{
|
{
|
||||||
@ -31,15 +33,9 @@ public function handle(): void
|
|||||||
{
|
{
|
||||||
$maintenances = Maintenance::all();
|
$maintenances = Maintenance::all();
|
||||||
foreach ($maintenances as $maintenance) {
|
foreach ($maintenances as $maintenance) {
|
||||||
$valid = CronExpression::isValidExpression($maintenance->schedule);
|
$cron = new CronCronExpression($maintenance->schedule);
|
||||||
if (!$valid) {
|
|
||||||
dd($maintenance->schedule);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$cron = new CronExpression($maintenance->schedule);
|
|
||||||
$maintenancePlanned = $maintenance->history()->create([
|
$maintenancePlanned = $maintenance->history()->create([
|
||||||
'start_at' => $cron->getNextRunDate(null, 2)
|
'start_at' => Carbon::createFromTimestamp($cron->getNext()),
|
||||||
]);
|
]);
|
||||||
$maintenancePlanned->refresh();
|
$maintenancePlanned->refresh();
|
||||||
|
|
||||||
@ -58,6 +54,5 @@ public function handle(): void
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
die();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,4 +37,16 @@ public function renderColumnMaintenanceName($val, $row)
|
|||||||
$ret = '<a href="' . route('maintenance.planned.detail', $row['id']) . '">' . e($val) . '</a>';
|
$ret = '<a href="' . route('maintenance.planned.detail', $row['id']) . '">' . e($val) . '</a>';
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function actions($item)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'type' => "livewire",
|
||||||
|
'action' => "remove",
|
||||||
|
'text' => "remove",
|
||||||
|
'parameters' => $item['id']
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.2",
|
"php": "^8.2",
|
||||||
"dragonmantank/cron-expression": "^3.3",
|
|
||||||
"laravel/framework": "^11.9",
|
"laravel/framework": "^11.9",
|
||||||
"laravel/sanctum": "^4.0",
|
"laravel/sanctum": "^4.0",
|
||||||
"laravel/tinker": "^2.9",
|
"laravel/tinker": "^2.9",
|
||||||
|
"poliander/cron": "^3.1",
|
||||||
"steelants/laravel-boilerplate": "^1.2"
|
"steelants/laravel-boilerplate": "^1.2"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
46
composer.lock
generated
46
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "07da4413e8866ce0abc6ed9d0e274725",
|
"content-hash": "3e780887adb9744dd78e2b2908185416",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "brick/math",
|
"name": "brick/math",
|
||||||
@ -2532,6 +2532,50 @@
|
|||||||
],
|
],
|
||||||
"time": "2024-07-20T21:41:07+00:00"
|
"time": "2024-07-20T21:41:07+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "poliander/cron",
|
||||||
|
"version": "3.1.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/poliander/cron.git",
|
||||||
|
"reference": "9e037c06aab233787999dfba38f1a12d100510c1"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/poliander/cron/zipball/9e037c06aab233787999dfba38f1a12d100510c1",
|
||||||
|
"reference": "9e037c06aab233787999dfba38f1a12d100510c1",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "8.1.* || 8.2.* || 8.3.*"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "~10.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Poliander\\Cron\\": "src/Cron/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"GPL-3.0-or-later"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "René Pollesch",
|
||||||
|
"role": "Developer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Standard (V7) compliant crontab expression parser/validator with support for time zones",
|
||||||
|
"homepage": "https://github.com/poliander/cron",
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/poliander/cron/issues",
|
||||||
|
"source": "https://github.com/poliander/cron/tree/3.1.0"
|
||||||
|
},
|
||||||
|
"time": "2023-11-23T21:56:03+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "psr/clock",
|
"name": "psr/clock",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
|
Loading…
Reference in New Issue
Block a user