Fix UpdateAvailabilityWithSchedulesJob logic error
This commit is contained in:
parent
1a221be19f
commit
06af68cb61
|
@ -41,6 +41,19 @@ class UpdateAvailabilityWithSchedulesJob implements ShouldQueue
|
||||||
["slot", "=", $curr_slot]
|
["slot", "=", $curr_slot]
|
||||||
])->pluck("user");
|
])->pluck("user");
|
||||||
|
|
||||||
|
$curr_day_slot_before = $curr_day;
|
||||||
|
$slot_before = $curr_slot - 1;
|
||||||
|
if($slot_before < 0) {
|
||||||
|
$curr_day_slot_before = $curr_day_slot_before - 1;
|
||||||
|
if($curr_day_slot_before < 0)
|
||||||
|
$curr_day_slot_before = 6;
|
||||||
|
$slot_before = 47;
|
||||||
|
}
|
||||||
|
$scheduled_users_slot_before = ScheduleSlots::where([
|
||||||
|
["day", "=", $curr_day_slot_before],
|
||||||
|
["slot", "=", $slot_before]
|
||||||
|
])->pluck("user");
|
||||||
|
|
||||||
$available_users_count_before = User::where('available', true)->where('hidden', false)->count();
|
$available_users_count_before = User::where('available', true)->where('hidden', false)->count();
|
||||||
|
|
||||||
User::whereIn("id", $scheduled_users)
|
User::whereIn("id", $scheduled_users)
|
||||||
|
@ -60,7 +73,8 @@ class UpdateAvailabilityWithSchedulesJob implements ShouldQueue
|
||||||
$last_availability_change = $user->last_availability_change;
|
$last_availability_change = $user->last_availability_change;
|
||||||
$new_last_availability_change = now();
|
$new_last_availability_change = now();
|
||||||
|
|
||||||
if(!is_null($last_availability_change)) {
|
$was_last_user_slot_active = in_array($user->id, $scheduled_users_slot_before->toArray());
|
||||||
|
if(!is_null($last_availability_change) && $was_last_user_slot_active) {
|
||||||
$diff = $new_last_availability_change->diffInMinutes($last_availability_change);
|
$diff = $new_last_availability_change->diffInMinutes($last_availability_change);
|
||||||
if($diff > 0) $user->availability_minutes += $diff;
|
if($diff > 0) $user->availability_minutes += $diff;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue