Compare commits
50 Commits
dhana-dev
...
45b8c1fbb4
| Author | SHA1 | Date | |
|---|---|---|---|
| 45b8c1fbb4 | |||
|
|
005ea2cf87 | ||
| 6015968043 | |||
| 2bc8584e7a | |||
| d126e931c8 | |||
| 62bf68ad2e | |||
| c6c63dcb35 | |||
| d1663ae58a | |||
| deb46cdda2 | |||
| 002bdc597d | |||
| a406d1b58a | |||
| 58d0b9f0ae | |||
| c0d8ca7b1e | |||
| f31ab62ec0 | |||
| 4285a31f94 | |||
| 0c9228bfec | |||
| 58b45c849d | |||
| 61a2e7ffad | |||
| 3779cf3e3b | |||
| acf955dd94 | |||
| 0de49f14ce | |||
| 0473ca33cf | |||
| 8a01033459 | |||
| 0555f9faff | |||
| 8cbbaa4845 | |||
| cb6b201648 | |||
| c3089a147c | |||
| 45f0e39f73 | |||
| fe1e1b9918 | |||
| e20915ca82 | |||
| 58e6cbfac0 | |||
| 1ace049687 | |||
| e5e85a8eea | |||
| 555802ab35 | |||
| 587b743f12 | |||
| 42555d4a81 | |||
| fd1e554076 | |||
| 022654f192 | |||
| 55f1088fda | |||
| f9233f44d8 | |||
| e0fec6b07c | |||
| 6bda9c1459 | |||
| 39bdd3df57 | |||
| 5bcf0703d9 | |||
| 80e522b7e6 | |||
| ee101f80ea | |||
| 37a99d03c1 | |||
| 5fdced003a | |||
| 0b0bb90efb | |||
| 32ce6da2c1 |
4
.github/workflows/gemini-pr-review.yaml
vendored
4
.github/workflows/gemini-pr-review.yaml
vendored
@@ -36,8 +36,8 @@ jobs:
|
|||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-npm-global-
|
${{ runner.os }}-npm-global-
|
||||||
|
|
||||||
- name: Install Gemini CLI globally
|
# - name: Install Gemini CLI globally
|
||||||
run: npm install -g --loglevel=http @google/gemini-cli
|
# run: npm install -g --loglevel=http @google/gemini-cli
|
||||||
|
|
||||||
- name: Generate git diff and review with Gemini
|
- name: Generate git diff and review with Gemini
|
||||||
id: review
|
id: review
|
||||||
|
|||||||
162
app/Console/Commands/Scheduler.php
Normal file
162
app/Console/Commands/Scheduler.php
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
|
use App\Models\AlertMailRule;
|
||||||
|
|
||||||
|
|
||||||
|
class Scheduler extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
// protected $signature = 'app:scheduler';
|
||||||
|
|
||||||
|
protected $signature = 'custom:scheduler';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
// protected $description = 'Command description';
|
||||||
|
|
||||||
|
protected $description = 'Manually trigger scheduler logic';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*/
|
||||||
|
// public function handle()
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// }
|
||||||
|
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
|
||||||
|
// --- Production Rules ---
|
||||||
|
$productionRules = AlertMailRule::where('module', 'ProductionQuantities')
|
||||||
|
->where('rule_name', 'ProductionMail')
|
||||||
|
->select('plant', 'schedule_type')
|
||||||
|
->distinct()
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach ($productionRules as $rule) {
|
||||||
|
switch ($rule->schedule_type) {
|
||||||
|
case 'Live':
|
||||||
|
// Run every minute
|
||||||
|
\Artisan::call('send:production-report', [
|
||||||
|
'schedule_type' => $rule->schedule_type,
|
||||||
|
'plant' => $rule->plant,
|
||||||
|
]);
|
||||||
|
break;
|
||||||
|
case 'Hourly':
|
||||||
|
if (now()->minute == 0) {
|
||||||
|
\Artisan::call('send:production-report', [
|
||||||
|
'schedule_type' => $rule->schedule_type,
|
||||||
|
'plant' => $rule->plant,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'Daily':
|
||||||
|
if (now()->format('H:i') == '07:59') {
|
||||||
|
\Artisan::call('send:production-report', [
|
||||||
|
'schedule_type' => $rule->schedule_type,
|
||||||
|
'plant' => $rule->plant,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// --- Invoice Validation Rules ---
|
||||||
|
$invoiceRules = AlertMailRule::where('module', 'InvoiceValidation')
|
||||||
|
->select('plant', 'schedule_type')
|
||||||
|
->distinct()
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach ($invoiceRules as $rule) {
|
||||||
|
|
||||||
|
switch ($rule->schedule_type) {
|
||||||
|
case 'Live':
|
||||||
|
// Run every minute
|
||||||
|
\Artisan::call('send:invoice-report', [
|
||||||
|
'schedule_type' => $rule->schedule_type,
|
||||||
|
'plant' => $rule->plant,
|
||||||
|
]);
|
||||||
|
break;
|
||||||
|
case 'Hourly':
|
||||||
|
if (now()->minute == 0) {
|
||||||
|
\Artisan::call('send:invoice-report', [
|
||||||
|
'schedule_type' => $rule->schedule_type,
|
||||||
|
'plant' => $rule->plant,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'Daily':
|
||||||
|
if (now()->format('H:i') == '07:59') {
|
||||||
|
\Artisan::call('send:invoice-report', [
|
||||||
|
'schedule_type' => $rule->schedule_type,
|
||||||
|
'plant' => $rule->plant,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Invoice Data Report Rules ---
|
||||||
|
$invoiceDataRules = AlertMailRule::where('module', 'InvoiceDataReport')
|
||||||
|
->select('plant', 'schedule_type')
|
||||||
|
->distinct()
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach ($invoiceDataRules as $rule) {
|
||||||
|
|
||||||
|
switch ($rule->schedule_type) {
|
||||||
|
case 'Live':
|
||||||
|
// Run every minute
|
||||||
|
\Artisan::call('send:invoice-data-report', [
|
||||||
|
'schedule_type' => $rule->schedule_type,
|
||||||
|
'plant' => $rule->plant,
|
||||||
|
]);
|
||||||
|
break;
|
||||||
|
case 'Hourly':
|
||||||
|
if (now()->minute == 0) {
|
||||||
|
\Artisan::call('send:invoice-data-report', [
|
||||||
|
'schedule_type' => $rule->schedule_type,
|
||||||
|
'plant' => $rule->plant,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'Daily':
|
||||||
|
if (now()->format('H:i') == '10:00') {
|
||||||
|
\Artisan::call('send:invoice-data-report', [
|
||||||
|
'schedule_type' => $rule->schedule_type,
|
||||||
|
'plant' => $rule->plant,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper to call Artisan commands with parameters.
|
||||||
|
*/
|
||||||
|
protected function callArtisanCommand($commandName, $rule)
|
||||||
|
{
|
||||||
|
\Artisan::call($commandName, [
|
||||||
|
'schedule_type' => $rule->schedule_type,
|
||||||
|
'plant' => $rule->plant,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->info("Executed {$commandName} for plant: {$rule->plant}");
|
||||||
|
\Log::info("Executed {$commandName} for plant: {$rule->plant}");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
use Illuminate\Foundation\Inspiring;
|
use Illuminate\Foundation\Inspiring;
|
||||||
use Illuminate\Support\Facades\Artisan;
|
use Illuminate\Support\Facades\Artisan;
|
||||||
use App\Models\AlertMailRule;
|
|
||||||
use Illuminate\Console\Scheduling\Schedule;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -11,87 +9,93 @@ Artisan::command('inspire', function () {
|
|||||||
$this->comment(Inspiring::quote());
|
$this->comment(Inspiring::quote());
|
||||||
})->purpose('Display an inspiring quote');
|
})->purpose('Display an inspiring quote');
|
||||||
|
|
||||||
|
|
||||||
|
Artisan::command('auto:scheduler', function () {
|
||||||
|
$this->call('custom:scheduler');
|
||||||
|
})->everyMinute();
|
||||||
|
|
||||||
|
|
||||||
// Schedule::command('send:invoice-report');
|
// Schedule::command('send:invoice-report');
|
||||||
// Schedule::command('send:production-report');
|
// Schedule::command('send:production-report');
|
||||||
|
|
||||||
app()->booted(function () {
|
// app()->booted(function () {
|
||||||
$schedule = app(Schedule::class);
|
// $schedule = app(Schedule::class);
|
||||||
|
|
||||||
// $schedule->command('report:send-daily-production')->dailyAt('07:59');
|
// // $schedule->command('report:send-daily-production')->dailyAt('07:59');
|
||||||
// Production report scheduling
|
// // Production report scheduling
|
||||||
$productionRules = AlertMailRule::where('module', 'ProductionQuantities')
|
// $productionRules = AlertMailRule::where('module', 'ProductionQuantities')
|
||||||
->where('rule_name', 'ProductionMail')
|
// ->where('rule_name', 'ProductionMail')
|
||||||
->select('plant', 'schedule_type')
|
// ->select('plant', 'schedule_type')
|
||||||
->distinct()
|
// ->distinct()
|
||||||
->get();
|
// ->get();
|
||||||
|
|
||||||
foreach ($productionRules as $rule) {
|
// foreach ($productionRules as $rule) {
|
||||||
$type = $rule->schedule_type;
|
// $type = $rule->schedule_type;
|
||||||
$plantId = $rule->plant;
|
// $plantId = $rule->plant;
|
||||||
|
|
||||||
$command = $schedule->command('send:production-report', [$type, $plantId]);
|
// $command = $schedule->command('send:production-report', [$type, $plantId]);
|
||||||
// ->appendOutputTo(storage_path('logs/scheduler.log'));
|
// // ->appendOutputTo(storage_path('logs/scheduler.log'));
|
||||||
|
|
||||||
switch ($type) {
|
// switch ($type) {
|
||||||
case 'Live':
|
// case 'Live':
|
||||||
$command->everyMinute();
|
// $command->everyMinute();
|
||||||
break;
|
// break;
|
||||||
case 'Hourly':
|
// case 'Hourly':
|
||||||
$command->hourly();
|
// $command->hourly();
|
||||||
break;
|
// break;
|
||||||
case 'Daily':
|
// case 'Daily':
|
||||||
$command->dailyAt('07:59');
|
// $command->dailyAt('07:59');
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Invoice report scheduling
|
// // Invoice report scheduling
|
||||||
$invoiceRules = AlertMailRule::where('module', 'InvoiceValidation')
|
// $invoiceRules = AlertMailRule::where('module', 'InvoiceValidation')
|
||||||
->select('plant', 'schedule_type')
|
// ->select('plant', 'schedule_type')
|
||||||
->distinct()
|
// ->distinct()
|
||||||
->get();
|
// ->get();
|
||||||
|
|
||||||
foreach ($invoiceRules as $rule) {
|
// foreach ($invoiceRules as $rule) {
|
||||||
$type = $rule->schedule_type;
|
// $type = $rule->schedule_type;
|
||||||
$plantId = $rule->plant;
|
// $plantId = $rule->plant;
|
||||||
|
|
||||||
$command = $schedule->command('send:invoice-report', [$type, $plantId]);
|
// $command = $schedule->command('send:invoice-report', [$type, $plantId]);
|
||||||
|
|
||||||
switch ($type) {
|
// switch ($type) {
|
||||||
case 'Live':
|
// case 'Live':
|
||||||
$command->everyMinute();
|
// $command->everyMinute();
|
||||||
break;
|
// break;
|
||||||
case 'Hourly':
|
// case 'Hourly':
|
||||||
$command->hourly();
|
// $command->hourly();
|
||||||
break;
|
// break;
|
||||||
case 'Daily':
|
// case 'Daily':
|
||||||
$command->dailyAt('07:59');
|
// $command->dailyAt('07:59');
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Invoice Data Report Scheduling
|
// // Invoice Data Report Scheduling
|
||||||
$invoiceDataRules = AlertMailRule::where('module', 'InvoiceDataReport')
|
// $invoiceDataRules = AlertMailRule::where('module', 'InvoiceDataReport')
|
||||||
->select('plant', 'schedule_type')
|
// ->select('plant', 'schedule_type')
|
||||||
->distinct()
|
// ->distinct()
|
||||||
->get();
|
// ->get();
|
||||||
|
|
||||||
foreach ($invoiceDataRules as $rule) {
|
// foreach ($invoiceDataRules as $rule) {
|
||||||
$type = $rule->schedule_type;
|
// $type = $rule->schedule_type;
|
||||||
$plantId = $rule->plant;
|
// $plantId = $rule->plant;
|
||||||
|
|
||||||
$command = $schedule->command('send:invoice-data-report', [$type, $plantId]);
|
// $command = $schedule->command('send:invoice-data-report', [$type, $plantId]);
|
||||||
|
|
||||||
switch ($type) {
|
// switch ($type) {
|
||||||
case 'Live':
|
// case 'Live':
|
||||||
$command->everyMinute();
|
// $command->everyMinute();
|
||||||
break;
|
// break;
|
||||||
case 'Hourly':
|
// case 'Hourly':
|
||||||
$command->hourly();
|
// $command->hourly();
|
||||||
break;
|
// break;
|
||||||
case 'Daily':
|
// case 'Daily':
|
||||||
$command->dailyAt('10:00');
|
// $command->dailyAt('10:00');
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|||||||
Reference in New Issue
Block a user