Convert models to use new search includes mechanism

This commit is contained in:
BrokenEagle
2020-07-19 03:42:51 +00:00
parent c141a358bd
commit c4009efccd
36 changed files with 208 additions and 125 deletions

View File

@@ -48,10 +48,6 @@ class WikiPage < ApplicationRecord
end
end
def tag_matches(params)
where(title: Tag.search(params).select(:name).reorder(nil))
end
def linked_to(title)
where(dtext_links: DtextLink.wiki_page.wiki_link.where(link_target: normalize_title(title)))
end
@@ -78,10 +74,6 @@ class WikiPage < ApplicationRecord
q = q.other_names_match(params[:other_names_match])
end
if params[:tag].present?
q = q.tag_matches(params[:tag])
end
if params[:linked_to].present?
q = q.linked_to(params[:linked_to])
end
@@ -245,6 +237,14 @@ class WikiPage < ApplicationRecord
end
end
def self.model_restriction(table)
super.where(table[:is_deleted].eq(false))
end
def self.searchable_includes
[:tag, :artist, :dtext_links]
end
def self.available_includes
[:tag, :artist, :dtext_links]
end