From: Daniel Karbach Date: Fri, 6 Sep 2024 10:26:05 +0000 (+0200) Subject: larger channel limit and better order X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=d9d1058e869431e75d4d8ba6cb6f4714319f4918;p=alttp.git larger channel limit and better order --- diff --git a/app/Http/Controllers/ChannelController.php b/app/Http/Controllers/ChannelController.php index cb16abb..ae57e31 100644 --- a/app/Http/Controllers/ChannelController.php +++ b/app/Http/Controllers/ChannelController.php @@ -17,10 +17,13 @@ class ChannelController extends Controller { 'id' => 'array', 'id.*' => 'integer|numeric', 'joinable' => 'boolean|nullable', + 'limit' => 'numeric|nullable', 'manageable' => 'boolean|nullable', 'phrase' => 'string|nullable', ]); + $limit = isset($validatedData['limit']) ? $validatedData['limit'] : 100; + $channels = Channel::query(); if (!empty($validatedData['id'])) { $channels = $channels->whereIn('id', $validatedData['id']); @@ -44,7 +47,11 @@ class ChannelController extends Controller { $channels = $channels->where('title', 'LIKE', '%'.$validatedData['phrase'].'%') ->orWhere('short_name', 'LIKE', '%'.$validatedData['phrase'].'%'); } - $channels = $channels->limit(5); + $channels + ->orderBy('twitch_live', 'DESC') + ->orderBy('twitch_viewers', 'DESC') + ->orderBy('title', 'ASC') + ->limit($limit); return $this->sendChannels($channels->get()); } diff --git a/resources/js/components/common/ChannelSelect.js b/resources/js/components/common/ChannelSelect.js index 355b02b..61b34e9 100644 --- a/resources/js/components/common/ChannelSelect.js +++ b/resources/js/components/common/ChannelSelect.js @@ -47,6 +47,7 @@ const ChannelSelect = ({ const response = await axios.get(`/api/channels`, { params: { joinable: joinable ? 1 : 0, + limit: 5, manageable: manageable ? 1 : 0, phrase, },