mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-24 17:06:18 -05:00
Perserving ts_rank when searching.
This commit is contained in:
parent
f9c02608e6
commit
b81e00ff3d
8 changed files with 30 additions and 23 deletions
|
|
@ -6,7 +6,7 @@ import sqlalchemy
|
|||
from modules.videos.common import apply_info_json
|
||||
from modules.videos.lib import parse_video_file_name, validate_video, get_statistics
|
||||
from modules.videos.models import Video
|
||||
from modules.videos.video.lib import video_search
|
||||
from modules.videos.video.lib import search_videos
|
||||
from wrolpi.files import lib as files_lib
|
||||
from wrolpi.files.models import File
|
||||
|
||||
|
|
@ -27,19 +27,19 @@ def test_search_censored_videos(test_session, simple_channel, video_factory):
|
|||
|
||||
# All source_ids are in the entries.
|
||||
set_entries(map(str, range(50)))
|
||||
videos, total = video_search(filters=['censored'], order_by='id', limit=20)
|
||||
videos, total = search_videos(filters=['censored'], order_by='id', limit=20)
|
||||
assert [i['video']['source_id'] for i in videos] == []
|
||||
assert total == 0
|
||||
|
||||
# First 5 are censored.
|
||||
set_entries(map(str, range(5, 50)))
|
||||
videos, total = video_search(filters=['censored'], order_by='id', limit=20)
|
||||
videos, total = search_videos(filters=['censored'], order_by='id', limit=20)
|
||||
assert [i['video']['source_id'] for i in videos] == [str(i) for i in range(5)]
|
||||
assert total == 5
|
||||
|
||||
# First 25 are censored.
|
||||
set_entries(map(str, range(25, 50)))
|
||||
videos, total = video_search(filters=['censored'], order_by='id', limit=20)
|
||||
videos, total = search_videos(filters=['censored'], order_by='id', limit=20)
|
||||
assert [i['video']['source_id'] for i in videos] == [str(i) for i in range(20)]
|
||||
assert total == 25
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ async def search(_: Request, body: schema.VideoSearchRequest):
|
|||
if body.order_by not in lib.VIDEO_ORDERS:
|
||||
raise InvalidOrderBy('Invalid order by')
|
||||
|
||||
files, videos_total = lib.video_search(
|
||||
files, videos_total = lib.search_videos(
|
||||
body.search_str,
|
||||
body.offset,
|
||||
body.limit,
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ DEFAULT_VIDEO_ORDER = 'rank'
|
|||
VIDEO_QUERY_LIMIT = 24
|
||||
|
||||
|
||||
def video_search(
|
||||
def search_videos(
|
||||
search_str: str = None,
|
||||
offset: int = None,
|
||||
limit: int = VIDEO_QUERY_LIMIT,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue