]> git.localhorst.tv Git - alttp.git/commitdiff
larger channel limit and better order
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Fri, 6 Sep 2024 10:26:05 +0000 (12:26 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Fri, 6 Sep 2024 10:26:05 +0000 (12:26 +0200)
app/Http/Controllers/ChannelController.php
resources/js/components/common/ChannelSelect.js

index cb16abba32852efc8794029833ec254e57a7f3e4..ae57e319e1a2d52bb19b2a6010bbbed5905fe1d1 100644 (file)
@@ -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());
        }
 
index 355b02b50d82824d0a3ff7ec6bc1901289c9ee9d..61b34e9adcf08db96d2ed4a46e4f4a6abee8fbff 100644 (file)
@@ -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,
                                },