feat(search): Implement 'never_broadcasted' filter for media search and add i…#206
Open
sreeshanth-soma wants to merge 1 commit intoopenbroadcaster:5.5-developfrom
Open
Conversation
…t to the advanced search UI.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes: #185
Summary
Adds a new "Never Been Broadcast" boolean filter to Advanced Search, allowing users to find media that has never been played by any player. Designed to help narrow down material hidden in the archive and to support dynamic sections for unplayed content.
Problem
In large databases (e.g., CJUC with 166K+ media items), an estimated 20–30% of media has never been played. There was no way to search for or identify this unplayed content.
Changes
Backend — core/models/media_model.php
'never_broadcasted'to$allowed_filtersin search_filters_validate()NOT EXISTS (SELECT 1 FROM players_log WHERE players_log.media_id = media.id)EXISTS (SELECT 1 FROM players_log WHERE players_log.media_id = media.id)Frontend — public/html/sidebar/advanced_search.html
<option value="never_broadcasted" ...>Never Been Broadcast</option>as a boolean filter (Yes/No)Performance
Uses
NOT EXISTSwith a correlated subquery — the most efficient SQL pattern for this use case:players_log)LEFT JOINwhich multiplies rows for media broadcast multiple times)COUNT(*)/HAVINGapproaches)players_log.media_idis already indexed (MULkey), so lookups are O(log n)LIMIT/OFFSET, so only one page is returned at a timeExpected query time at 170K items: sub-second (~50–200ms with index).
Verification
players_logentry for one media item to simulate a broadcast