From: Daniel Karbach Date: Sun, 1 Oct 2023 10:42:26 +0000 (+0200) Subject: better schedule start X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=212561cf1c6724b52c490104f5a2b4c3418b1c62;p=alttp.git better schedule start --- diff --git a/app/Http/Controllers/EpisodeController.php b/app/Http/Controllers/EpisodeController.php index 9892cee..4e93427 100644 --- a/app/Http/Controllers/EpisodeController.php +++ b/app/Http/Controllers/EpisodeController.php @@ -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') diff --git a/resources/js/pages/Schedule.js b/resources/js/pages/Schedule.js index 7c402e6..bf36c71 100644 --- a/resources/js/pages/Schedule.js +++ b/resources/js/pages/Schedule.js @@ -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, },