mirror of
https://github.com/iv-org/invidious.git
synced 2025-08-16 01:28:29 +00:00
Moved content array walker to Category#to_json
As requested by reviewer this change moves the content array walker from the API endpoint to the Category class.
This commit is contained in:
parent
d37b69fb20
commit
a8e3349577
@ -238,7 +238,13 @@ class Category
|
||||
def to_json(locale, json : JSON::Builder)
|
||||
json.object do
|
||||
json.field "title", self.title
|
||||
json.field "contents", self.contents
|
||||
json.field "contents" do
|
||||
json.array do
|
||||
self.contents.each do |item|
|
||||
item.to_json(locale, json)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -36,13 +36,7 @@ module Invidious::Routes::API::V1::Search
|
||||
JSON.build do |json|
|
||||
json.array do
|
||||
search_results.each do |item|
|
||||
if item.is_a?(Category)
|
||||
item.contents.each do |cat_item|
|
||||
cat_item.to_json(locale, json)
|
||||
end
|
||||
else
|
||||
item.to_json(locale, json)
|
||||
end
|
||||
item.to_json(locale, json)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user