Extract items from category for search in frontend

This commit is contained in:
syeopite 2021-05-24 11:09:23 -07:00
parent f44a5b1a69
commit c9d49dd5a6
No known key found for this signature in database
GPG key ID: 6FA616E5A5294A82

View file

@ -232,5 +232,20 @@ def process_search_query(url_params, query, page, user, region)
count, items = search(search_query, search_params, region).as(Tuple)
end
{search_query, count, items, url_params}
# Light processing to extract items from categories.
# Categories should ideally be supported in the frontend in the future
extracted_items = [] of SearchItem | ChannelVideo
items.each do |i|
if i.is_a? Category
i.contents.each do |cate_items|
if cate_items.is_a? (SearchVideo | SearchPlaylist | SearchChannel)
extracted_items << cate_items
end
end
else
extracted_items << i
end
end
{search_query, count, extracted_items, url_params}
end