Extra logging for cron and add flight visible field
This commit is contained in:
@@ -7,6 +7,8 @@ use App\Interfaces\Listener;
|
||||
use App\Models\Enums\Days;
|
||||
use App\Models\Flight;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Figure out what flights need to be active for today
|
||||
@@ -39,11 +41,19 @@ class SetActiveFlights extends Listener
|
||||
*/
|
||||
foreach($flights as $flight) {
|
||||
|
||||
if (!$flight->active) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// dates aren't set, so just save if there were any changes above
|
||||
// and move onto the next one
|
||||
if ($flight->start_date === null || $flight->end_date === null) {
|
||||
if ($flight->days > 0) {
|
||||
$flight->active = Days::isToday($flight->days);
|
||||
$visible = Days::isToday($flight->days);
|
||||
if($flight->visible !== $visible) {
|
||||
Log::info('Marking flight '.$flight->ident.' to '.($visible ? 'visible' : 'invisible'));
|
||||
$flight->visible = $visible;
|
||||
}
|
||||
}
|
||||
|
||||
$flight->save();
|
||||
@@ -55,13 +65,17 @@ class SetActiveFlights extends Listener
|
||||
// Start/end date is set, so make sure today is valid for it to be alive
|
||||
// and then make sure if days of the week are specified, check that too
|
||||
if ($today->gte($flight->start_date) && $today->lte($flight->end_date)) {
|
||||
if ($flight->days > 0) {
|
||||
$flight->active = Days::isToday($flight->days);
|
||||
if ($flight->days === null || $flight->days > 0) {
|
||||
$visible = Days::isToday($flight->days);
|
||||
if($flight->visible !== $visible) {
|
||||
Log::info('Toggling flight '.$flight->ident.' to '.($visible?'visible':'invisible'));
|
||||
$flight->visible = true;
|
||||
}
|
||||
} else {
|
||||
$flight->active = true;
|
||||
$flight->visible = true;
|
||||
}
|
||||
} else {
|
||||
$flight->active = false;
|
||||
$flight->visible = false;
|
||||
}
|
||||
|
||||
$flight->save();
|
||||
|
||||
Reference in New Issue
Block a user