Significantly cleans up the listing and isn't needed to see in bulk. Some sites disable thanks completely and don't want to see it. I plan to also move the comment count and the seeding/leeching indicators elsewhere in a separate PR to clean it up further. The count is still shown on the individual torrent page itself.
When selecting the torrents after determining which groups to select from, all torrents within the groups were selected instead of only the torrents matching the search filters. Fix by applying the meilisearch filters to the torrents, plucking their ids, then fetching torrents matching those ids from mysql.
Regression from #4851
Caused by the mysql and meilisearch filters not matching. The mysql filters were being applied to the torrent fetching, even though meilisearch was intended to be used to find the works, and mysql was to be used to find all torrents belonging to each word by its id. The main problem was any field using LIKE didn't match with meilisearch's search engine. This was fixed by appropriate conditionally applying the sql filters. Additionally, the torrents were filtering by `imdb > 0`, but meilisearch was including null imdbs when searching by `>` unlike mysql. Fixed that by changing it to `IS NOT NULL` instead.
Cleans up the code to remove null coalescing on user_settings when it doesn't exist. Sometimes null was unintentionally being cast to false. Allowing the user_setting remain optional allows the site administration to configure and change defaults for their users without it affecting users who have explicitly chosen their existing user settings.
Alternative to #4789
The aggregates need to be executed before `select` or else `select` removes the aggregates from the query. Also made all the grouped torrent queries consistent and added aggregates where they were missing.
Shaves 110ms (from 150 ms to 40ms) from the logic to group torrents per tmdb and media type. It's not much compared to the rest of the request (~2s), but it's something. I could've got it down to 11 ms if laravel didn't have high overhead when accessing attributes, but it was 70ms before I started using ->getAttributeValue so that says something there.
When the featured flag goes out of sync with the featured_torrents table (for reasons still unknown), the torrent is permanently labeled as freeleech, while 100% of traffic is always credited.
Just an initial portion for now fixing incorrect text and preventing future incorrect text. Eventually, I'd like to fix everything still listed under "ignoredWords" in cspell.json.
There's no easy way of adding these to meilisearch right now. Indexing them is inefficient and causes multi-second queries. It would be useful to use the `CONTAINS` operator to search these, but that meilisearch feature is still experimental and we should wait until it's stable before using it.
We need to sort the torrents after they've been fetched from the database to match the same order that meilisearch returned.
Fixes regression from #4236.
Using scout directly doesn't work because when increasing the maxTotalHits in meilisearch, scout will use the max instead of just fetching the current page. Meilisearch seems to handle a max of 200k torrents fine on its own, with 12ms latency when e.g. filtering by type down to 38000 totalHits. Run `php artisan scout:sync-index-settings`, followed by `php artisan auto:sync_torrents_to_meilisearch` after updating.