]> git.localhorst.tv Git - alttp.git/commitdiff
better schedule start
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 1 Oct 2023 10:42:26 +0000 (12:42 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 1 Oct 2023 10:42:26 +0000 (12:42 +0200)
app/Http/Controllers/EpisodeController.php
resources/js/pages/Schedule.js

index 9892cee7b2a88f0eca0848a26f78ca15e8fb6426..4e93427836287daea50cf6645cfaa638c5d22b59 100644 (file)
@@ -8,6 +8,7 @@ use App\Models\EpisodeCrew;
 use App\Models\User;
 use Carbon\Carbon;
 use Illuminate\Http\Request;
+use Illuminate\Support\Facades\DB;
 
 class EpisodeController extends Controller
 {
@@ -194,13 +195,13 @@ class EpisodeController extends Controller
                        'event' => 'nullable|array',
                        'event.*' => 'numeric',
                ]);
-               $after = isset($validatedData['after']) ? $validatedData['after'] : Carbon::now()->sub(2, 'hours');
+               $after = isset($validatedData['after']) ? $validatedData['after'] : Carbon::now();
                $before = isset($validatedData['before']) ? $validatedData['before'] : Carbon::now()->add(1, 'days');
                $episodes = Episode::with(['channels', 'event', 'players', 'players.user'])
                        ->select('episodes.*')
                        ->join('events', 'episodes.event_id', '=', 'events.id')
                        ->where('episodes.confirmed', '=', true)
-                       ->where('episodes.start', '>=', $after)
+                       ->where(DB::raw('DATE_ADD(`episodes`.`start`, INTERVAL COALESCE(`episodes`.`estimate`, 0) SECOND)'), '>=', $after)
                        ->where('episodes.start', '<=', $before)
                        ->where('events.visible', '=', true)
                        ->orderBy('episodes.start')
index 7c402e647b2208985f39591944e91090d0d44342..bf36c710163cf546c1edd43f553c2459cd18bd28 100644 (file)
@@ -87,7 +87,7 @@ const Schedule = ({ user }) => {
                axios.get(`/api/episodes`, {
                        signal: controller.signal,
                        params: {
-                               after: moment().subtract(8, 'hours').subtract(behind, 'days').toISOString(),
+                               after: moment().subtract(2, 'hours').subtract(behind, 'days').toISOString(),
                                before: moment().add(16, 'hours').add(ahead, 'days').toISOString(),
                                ...filter,
                        },