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

@@ -18,15 +18,9 @@ class CommentVote < ApplicationRecord
end
end
def self.comment_matches(params)
return all if params.blank?
where(comment_id: Comment.search(params).reorder(nil).select(:id))
end
def self.search(params)
q = super
q = q.search_attributes(params, :comment_id, :user, :score)
q = q.comment_matches(params[:comment])
q = q.search_attributes(params, :score)
q.apply_default_order(params)
end
@@ -44,6 +38,10 @@ class CommentVote < ApplicationRecord
score == -1
end
def self.searchable_includes
[:comment, :user]
end
def self.available_includes
[:comment, :user]
end