Convert models to use new search includes mechanism
This commit is contained in:
@@ -1296,12 +1296,12 @@ class Post < ApplicationRecord
|
||||
def search(params)
|
||||
q = super
|
||||
|
||||
q = q.search_attributes(params,
|
||||
:approver, :uploader, :rating, :source, :pixiv_id, :fav_count, :score, :up_score,
|
||||
:down_score, :md5, :file_ext, :file_size, :image_width, :image_height, :tag_count,
|
||||
:parent, :has_children, :has_active_children, :is_note_locked, :is_rating_locked,
|
||||
:is_status_locked, :is_pending, :is_flagged, :is_deleted, :is_banned,
|
||||
:last_comment_bumped_at, :last_commented_at, :last_noted_at
|
||||
q = q.search_attributes(
|
||||
params,
|
||||
:rating, :source, :pixiv_id, :fav_count, :score, :up_score, :down_score, :md5, :file_ext,
|
||||
:file_size, :image_width, :image_height, :tag_count, :has_children, :has_active_children,
|
||||
:is_note_locked, :is_rating_locked, :is_status_locked, :is_pending, :is_flagged, :is_deleted,
|
||||
:is_banned, :last_comment_bumped_at, :last_commented_at, :last_noted_at
|
||||
)
|
||||
|
||||
if params[:tags].present?
|
||||
@@ -1513,6 +1513,14 @@ class Post < ApplicationRecord
|
||||
super + [:has_large?, :current_image_size]
|
||||
end
|
||||
|
||||
def self.model_restriction(table)
|
||||
super.where(table[:is_pending].eq(false)).where(table[:is_flagged].eq(false)).where(table[:is_deleted].eq(false))
|
||||
end
|
||||
|
||||
def self.searchable_includes
|
||||
[:uploader, :updater, :approver, :parent, :upload, :artist_commentary, :flags, :appeals, :notes, :comments, :children, :approvals, :replacements, :pixiv_ugoira_frame_data]
|
||||
end
|
||||
|
||||
def self.available_includes
|
||||
[:uploader, :updater, :approver, :parent, :upload, :artist_commentary, :flags, :appeals, :notes, :comments, :children, :approvals, :replacements, :pixiv_ugoira_frame_data]
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user