1
0
forked from poc/pds

changed logic for only production mail alert only

This commit is contained in:
dhanabalan
2025-07-09 10:30:06 +05:30
parent 6d6d3f2d60
commit fec85824c2

View File

@@ -141,23 +141,30 @@ Artisan::command('inspire', function () {
app()->booted(function () {
$schedule = app(Schedule::class);
//Always run every minute — the command itself will filter recipients
//$schedule->command('send:production-report')->everyMinute();
// Production Report Scheduling
$productionScheduleType = AlertMailRule::where('module', 'ProductionQuantities')
// Get all production rules with logging
$productionRules = AlertMailRule::where('module', 'ProductionQuantities')
->where('rule_name', 'ProductionMail')
->value('schedule_type');
->get();
if ($productionScheduleType) {
$command = $schedule->command('send:production-report');
foreach ($productionRules as $rule) {
$command = $schedule->command("send:production-report --email={$rule->email}");
match ($productionScheduleType) {
'Live' => $command->everyMinute(),
'Hourly' => $command->hourly(),
'Daily' => $command->dailyAt('07:59'),
default => null,
};
switch ($rule->schedule_type) {
case 'Live':
$command->everyMinute();
Log::info("Scheduled Live production report for {$rule->email}");
break;
case 'Hourly':
$command->hourly();
Log::info("Scheduled Hourly production report for {$rule->email}");
break;
case 'Daily':
$command->dailyAt('07:59');
Log::info("Scheduled Daily production report for {$rule->email}");
break;
}
}
});