Move all order logic to models
- Have a default order for each model -- The overall default is ID DESC - Allow for custom orderings -- When comma-separated IDs are used
This commit is contained in:
@@ -16,6 +16,28 @@ class ApplicationRecord < ActiveRecord::Base
|
||||
PostQueryBuilder.new(nil).add_range_relation(parsed_range, qualified_column, self)
|
||||
end
|
||||
|
||||
def apply_default_order(params)
|
||||
if params[:order] == "custom"
|
||||
parse_ids = Tag.parse_helper(params[:id])
|
||||
if parse_ids[0] == :in
|
||||
return find_ordered(parse_ids[1])
|
||||
end
|
||||
end
|
||||
return default_order
|
||||
end
|
||||
|
||||
def default_order
|
||||
order(id: :desc)
|
||||
end
|
||||
|
||||
def find_ordered(ids)
|
||||
order_clause = []
|
||||
ids.each do |id|
|
||||
order_clause << sanitize_sql_array(["ID=? DESC", id])
|
||||
end
|
||||
where(id: ids).order(order_clause.join(', '))
|
||||
end
|
||||
|
||||
def search(params = {})
|
||||
params ||= {}
|
||||
|
||||
@@ -23,6 +45,7 @@ class ApplicationRecord < ActiveRecord::Base
|
||||
q = q.attribute_matches(:id, params[:id])
|
||||
q = q.attribute_matches(:created_at, params[:created_at]) if attribute_names.include?("created_at")
|
||||
q = q.attribute_matches(:updated_at, params[:updated_at]) if attribute_names.include?("updated_at")
|
||||
|
||||
q
|
||||
end
|
||||
end
|
||||
|
||||
@@ -536,7 +536,6 @@ class Artist < ApplicationRecord
|
||||
|
||||
def search(params)
|
||||
q = super
|
||||
params = {} if params.blank?
|
||||
|
||||
case params[:name]
|
||||
when /^http/
|
||||
@@ -581,18 +580,6 @@ class Artist < ApplicationRecord
|
||||
q = q.url_matches(params[:url_matches])
|
||||
end
|
||||
|
||||
params[:order] ||= params.delete(:sort)
|
||||
case params[:order]
|
||||
when "name"
|
||||
q = q.order("artists.name")
|
||||
when "updated_at"
|
||||
q = q.order("artists.updated_at desc")
|
||||
when "post_count"
|
||||
q = q.includes(:tag).order("tags.post_count desc nulls last").references(:tags)
|
||||
else
|
||||
q = q.order("artists.id desc")
|
||||
end
|
||||
|
||||
if params[:is_active] == "true"
|
||||
q = q.active
|
||||
elsif params[:is_active] == "false"
|
||||
@@ -624,6 +611,18 @@ class Artist < ApplicationRecord
|
||||
q = q.includes(:tag).where("tags.name IS NULL OR tags.post_count <= 0").references(:tags)
|
||||
end
|
||||
|
||||
params[:order] ||= params.delete(:sort)
|
||||
case params[:order]
|
||||
when "name"
|
||||
q = q.order("artists.name")
|
||||
when "updated_at"
|
||||
q = q.order("artists.updated_at desc")
|
||||
when "post_count"
|
||||
q = q.includes(:tag).order("tags.post_count desc nulls last").order("artists.name").references(:tags)
|
||||
else
|
||||
q = q.apply_default_order(params)
|
||||
end
|
||||
|
||||
q
|
||||
end
|
||||
end
|
||||
|
||||
@@ -33,7 +33,6 @@ class ArtistCommentary < ApplicationRecord
|
||||
|
||||
def search(params)
|
||||
q = super
|
||||
params = {} if params.blank?
|
||||
|
||||
if params[:text_matches].present?
|
||||
q = q.text_matches(params[:text_matches])
|
||||
@@ -62,7 +61,7 @@ class ArtistCommentary < ApplicationRecord
|
||||
q = q.deleted if params[:is_deleted] == "yes"
|
||||
q = q.undeleted if params[:is_deleted] == "no"
|
||||
|
||||
q
|
||||
q.apply_default_order(params)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ class ArtistCommentaryVersion < ApplicationRecord
|
||||
|
||||
def self.search(params)
|
||||
q = super
|
||||
return q if params.blank?
|
||||
|
||||
if params[:updater_id]
|
||||
q = q.where("updater_id = ?", params[:updater_id].to_i)
|
||||
@@ -17,7 +16,7 @@ class ArtistCommentaryVersion < ApplicationRecord
|
||||
q = q.where("post_id = ?", params[:post_id].to_i)
|
||||
end
|
||||
|
||||
q
|
||||
q.apply_default_order(params)
|
||||
end
|
||||
|
||||
def initialize_updater
|
||||
|
||||
@@ -15,7 +15,6 @@ class ArtistVersion < ApplicationRecord
|
||||
|
||||
def search(params)
|
||||
q = super
|
||||
return q if params.blank?
|
||||
|
||||
if params[:name].present?
|
||||
q = q.where("name like ? escape E'\\\\'", params[:name].to_escaped_for_sql_like)
|
||||
@@ -33,13 +32,6 @@ class ArtistVersion < ApplicationRecord
|
||||
q = q.where(artist_id: params[:artist_id].split(",").map(&:to_i))
|
||||
end
|
||||
|
||||
params[:order] ||= params.delete(:sort)
|
||||
if params[:order] == "name"
|
||||
q = q.reorder("name")
|
||||
else
|
||||
q = q.reorder("id desc")
|
||||
end
|
||||
|
||||
if params[:is_active] == "true"
|
||||
q = q.where("is_active = true")
|
||||
elsif params[:is_active] == "false"
|
||||
@@ -52,6 +44,13 @@ class ArtistVersion < ApplicationRecord
|
||||
q = q.where("is_banned = false")
|
||||
end
|
||||
|
||||
params[:order] ||= params.delete(:sort)
|
||||
if params[:order] == "name"
|
||||
q = q.order("artist_versions.name").default_order
|
||||
else
|
||||
q = q.apply_default_order(params)
|
||||
end
|
||||
|
||||
q
|
||||
end
|
||||
end
|
||||
|
||||
@@ -27,7 +27,6 @@ class Ban < ApplicationRecord
|
||||
|
||||
def self.search(params)
|
||||
q = super
|
||||
return q if params.blank?
|
||||
|
||||
if params[:banner_name]
|
||||
q = q.where("banner_id = (select _.id from users _ where lower(_.name) = ?)", params[:banner_name].mb_chars.downcase)
|
||||
@@ -58,7 +57,7 @@ class Ban < ApplicationRecord
|
||||
when "expires_at_desc"
|
||||
q = q.order("bans.expires_at desc")
|
||||
else
|
||||
q = q.order("bans.id desc")
|
||||
q = q.apply_default_order(params)
|
||||
end
|
||||
|
||||
q
|
||||
|
||||
@@ -22,6 +22,10 @@ class BulkUpdateRequest < ApplicationRecord
|
||||
scope :pending_first, lambda { order("(case status when 'pending' then 0 when 'approved' then 1 else 2 end)") }
|
||||
|
||||
module SearchMethods
|
||||
def default_order
|
||||
pending_first.order(id: :desc)
|
||||
end
|
||||
|
||||
def search(params = {})
|
||||
q = super
|
||||
|
||||
@@ -63,8 +67,8 @@ class BulkUpdateRequest < ApplicationRecord
|
||||
q = q.order(updated_at: :desc)
|
||||
when "updated_at_asc"
|
||||
q = q.order(updated_at: :asc)
|
||||
when "status_desc"
|
||||
q = q.pending_first.order(id: :desc)
|
||||
else
|
||||
q = q.apply_default_order(params)
|
||||
end
|
||||
|
||||
q
|
||||
|
||||
@@ -131,7 +131,7 @@ class Comment < ApplicationRecord
|
||||
when "updated_at", "updated_at_desc"
|
||||
q = q.order("comments.updated_at DESC")
|
||||
else
|
||||
q = q.order("comments.id DESC")
|
||||
q = q.apply_default_order(params)
|
||||
end
|
||||
|
||||
q
|
||||
|
||||
@@ -187,7 +187,6 @@ class Dmail < ApplicationRecord
|
||||
|
||||
def search(params)
|
||||
q = super
|
||||
return q if params.blank?
|
||||
|
||||
if params[:title_matches].present?
|
||||
q = q.title_matches(params[:title_matches])
|
||||
@@ -225,7 +224,7 @@ class Dmail < ApplicationRecord
|
||||
q = q.unread
|
||||
end
|
||||
|
||||
q
|
||||
q.apply_default_order(params)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -39,13 +39,16 @@ class FavoriteGroup < ApplicationRecord
|
||||
elsif params[:is_public].present?
|
||||
where("is_public = ?", params[:is_public])
|
||||
else
|
||||
where("true")
|
||||
all
|
||||
end
|
||||
end
|
||||
|
||||
def default_order
|
||||
order(updated_at: :desc)
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = super
|
||||
params = {} if params.blank?
|
||||
|
||||
if params[:creator_id].present?
|
||||
user = User.find(params[:creator_id])
|
||||
@@ -64,7 +67,7 @@ class FavoriteGroup < ApplicationRecord
|
||||
q = q.name_matches(params[:name_matches])
|
||||
end
|
||||
|
||||
q
|
||||
q.apply_default_order(params)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -67,7 +67,6 @@ class ForumPost < ApplicationRecord
|
||||
def search(params)
|
||||
q = super
|
||||
q = q.permitted
|
||||
return q if params.blank?
|
||||
|
||||
if params[:creator_id].present?
|
||||
q = q.where("forum_posts.creator_id = ?", params[:creator_id].to_i)
|
||||
@@ -93,7 +92,7 @@ class ForumPost < ApplicationRecord
|
||||
q = q.joins(:topic).where("forum_topics.category_id = ?", params[:topic_category_id].to_i)
|
||||
end
|
||||
|
||||
q
|
||||
q.apply_default_order(params)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -75,6 +75,10 @@ class ForumTopic < ApplicationRecord
|
||||
order(is_sticky: :desc, updated_at: :desc)
|
||||
end
|
||||
|
||||
def default_order
|
||||
order(updated_at: :desc)
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = super
|
||||
q = q.permitted
|
||||
@@ -99,7 +103,7 @@ class ForumTopic < ApplicationRecord
|
||||
when "sticky"
|
||||
q = q.sticky_first
|
||||
else
|
||||
q = q.order(updated_at: :desc)
|
||||
q = q.apply_default_order(params)
|
||||
end
|
||||
|
||||
q
|
||||
|
||||
@@ -53,7 +53,6 @@ class ModAction < ApplicationRecord
|
||||
|
||||
def self.search(params)
|
||||
q = super
|
||||
return q if params.blank?
|
||||
|
||||
if params[:creator_id].present?
|
||||
q = q.where("creator_id = ?", params[:creator_id].to_i)
|
||||
@@ -67,7 +66,7 @@ class ModAction < ApplicationRecord
|
||||
q = q.attribute_matches(:category, params[:category])
|
||||
end
|
||||
|
||||
q
|
||||
q.apply_default_order(params)
|
||||
end
|
||||
|
||||
def category_id
|
||||
|
||||
@@ -43,7 +43,6 @@ class Note < ApplicationRecord
|
||||
|
||||
def search(params)
|
||||
q = super
|
||||
return q if params.blank?
|
||||
|
||||
if params[:body_matches].present?
|
||||
q = q.body_matches(params[:body_matches])
|
||||
@@ -71,7 +70,7 @@ class Note < ApplicationRecord
|
||||
q = q.where(creator_id: params[:creator_id].split(",").map(&:to_i))
|
||||
end
|
||||
|
||||
q
|
||||
q.apply_default_order(params)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ class NoteVersion < ApplicationRecord
|
||||
|
||||
def self.search(params)
|
||||
q = super
|
||||
return q if params.blank?
|
||||
|
||||
if params[:updater_id]
|
||||
q = q.where(updater_id: params[:updater_id].split(",").map(&:to_i))
|
||||
@@ -20,7 +19,7 @@ class NoteVersion < ApplicationRecord
|
||||
q = q.where(note_id: params[:note_id].split(",").map(&:to_i))
|
||||
end
|
||||
|
||||
q
|
||||
q.apply_default_order(params)
|
||||
end
|
||||
|
||||
def initialize_updater
|
||||
|
||||
@@ -49,9 +49,12 @@ class Pool < ApplicationRecord
|
||||
where("lower(pools.name) like ? escape E'\\\\'", name.to_escaped_for_sql_like)
|
||||
end
|
||||
|
||||
def default_order
|
||||
order(updated_at: :desc)
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = super
|
||||
params = {} if params.blank?
|
||||
|
||||
if params[:name_matches].present?
|
||||
q = q.name_matches(params[:name_matches])
|
||||
@@ -75,18 +78,6 @@ class Pool < ApplicationRecord
|
||||
q = q.where("pools.is_active = false")
|
||||
end
|
||||
|
||||
params[:order] ||= params.delete(:sort)
|
||||
case params[:order]
|
||||
when "name"
|
||||
q = q.order("pools.name")
|
||||
when "created_at"
|
||||
q = q.order("pools.created_at desc")
|
||||
when "post_count"
|
||||
q = q.order("pools.post_count desc")
|
||||
else
|
||||
q = q.order("pools.updated_at desc")
|
||||
end
|
||||
|
||||
if params[:category] == "series"
|
||||
q = q.series
|
||||
elsif params[:category] == "collection"
|
||||
@@ -99,6 +90,18 @@ class Pool < ApplicationRecord
|
||||
q = q.undeleted
|
||||
end
|
||||
|
||||
params[:order] ||= params.delete(:sort)
|
||||
case params[:order]
|
||||
when "name"
|
||||
q = q.order("pools.name")
|
||||
when "created_at"
|
||||
q = q.order("pools.created_at desc")
|
||||
when "post_count"
|
||||
q = q.order("pools.post_count desc").default_order
|
||||
else
|
||||
q = q.apply_default_order(params)
|
||||
end
|
||||
|
||||
q
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,7 +16,6 @@ class PoolArchive < ApplicationRecord
|
||||
|
||||
def search(params)
|
||||
q = super
|
||||
return q if params.blank?
|
||||
|
||||
if params[:updater_id].present?
|
||||
q = q.where(updater_id: params[:updater_id].split(",").map(&:to_i))
|
||||
@@ -30,7 +29,7 @@ class PoolArchive < ApplicationRecord
|
||||
q = q.where(pool_id: params[:pool_id].split(",").map(&:to_i))
|
||||
end
|
||||
|
||||
q
|
||||
q.apply_default_order(params)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ class PoolVersion < ApplicationRecord
|
||||
|
||||
def search(params)
|
||||
q = super
|
||||
return q if params.blank?
|
||||
|
||||
if params[:updater_id].present?
|
||||
q = q.for_user(params[:updater_id].to_i)
|
||||
@@ -28,7 +27,7 @@ class PoolVersion < ApplicationRecord
|
||||
q = q.where("pool_id = ?", params[:pool_id].to_i)
|
||||
end
|
||||
|
||||
q
|
||||
q.apply_default_order(params)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -45,8 +45,6 @@ class PostAppeal < ApplicationRecord
|
||||
|
||||
def search(params)
|
||||
q = super
|
||||
q = q.order("post_appeals.id desc")
|
||||
return q if params.blank?
|
||||
|
||||
if params[:reason_matches].present?
|
||||
q = q.reason_matches(params[:reason_matches])
|
||||
@@ -74,7 +72,7 @@ class PostAppeal < ApplicationRecord
|
||||
q = q.unresolved
|
||||
end
|
||||
|
||||
q
|
||||
q.apply_default_order(params)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ class PostArchive < ApplicationRecord
|
||||
|
||||
def search(params)
|
||||
q = super
|
||||
params = {} if params.blank?
|
||||
|
||||
if params[:updater_name].present?
|
||||
q = q.for_user_name(params[:updater_name])
|
||||
@@ -45,7 +44,7 @@ class PostArchive < ApplicationRecord
|
||||
q = q.where("id <= ?", params[:start_id].to_i)
|
||||
end
|
||||
|
||||
q
|
||||
q.apply_default_order(params)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -67,8 +67,6 @@ class PostFlag < ApplicationRecord
|
||||
|
||||
def search(params)
|
||||
q = super
|
||||
q = q.order("post_flags.id desc")
|
||||
return q if params.blank?
|
||||
|
||||
if params[:reason_matches].present?
|
||||
q = q.reason_matches(params[:reason_matches])
|
||||
@@ -122,7 +120,7 @@ class PostFlag < ApplicationRecord
|
||||
q = q.duplicate
|
||||
end
|
||||
|
||||
q
|
||||
q.apply_default_order(params)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -121,9 +121,7 @@ class PostReplacement < ApplicationRecord
|
||||
q = q.post_tags_match(params[:post_tags_match])
|
||||
end
|
||||
|
||||
q = q.order("created_at DESC")
|
||||
|
||||
q
|
||||
q.apply_default_order(params)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ class PostVersion < ApplicationRecord
|
||||
|
||||
def search(params)
|
||||
q = super
|
||||
params = {} if params.blank?
|
||||
|
||||
if params[:updater_name].present?
|
||||
q = q.updater_name(params[:updater_name])
|
||||
@@ -33,7 +32,7 @@ class PostVersion < ApplicationRecord
|
||||
q = q.where("id <= ?", params[:start_id].to_i)
|
||||
end
|
||||
|
||||
q
|
||||
q.apply_default_order(params)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -872,7 +872,6 @@ class Tag < ApplicationRecord
|
||||
|
||||
def search(params)
|
||||
q = super
|
||||
params = {} if params.blank?
|
||||
|
||||
if params[:fuzzy_name_matches].present?
|
||||
q = q.fuzzy_name_matches(params[:fuzzy_name_matches])
|
||||
@@ -909,15 +908,15 @@ class Tag < ApplicationRecord
|
||||
params[:order] ||= params.delete(:sort)
|
||||
case params[:order]
|
||||
when "name"
|
||||
q = q.reorder("name")
|
||||
q = q.order("name")
|
||||
when "date"
|
||||
q = q.reorder("id desc")
|
||||
q = q.order("id desc")
|
||||
when "count"
|
||||
q = q.reorder("post_count desc")
|
||||
q = q.order("post_count desc")
|
||||
when "similarity"
|
||||
q = q.order_similarity(params[:fuzzy_name_matches]) if params[:fuzzy_name_matches].present?
|
||||
else
|
||||
q = q.reorder("id desc")
|
||||
q = q.apply_default_order(params)
|
||||
end
|
||||
|
||||
q
|
||||
|
||||
@@ -72,6 +72,10 @@ class TagRelationship < ApplicationRecord
|
||||
where(status: %w[active processing queued])
|
||||
end
|
||||
|
||||
def default_order
|
||||
pending_first
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = super
|
||||
|
||||
@@ -97,8 +101,6 @@ class TagRelationship < ApplicationRecord
|
||||
|
||||
params[:order] ||= "status"
|
||||
case params[:order].downcase
|
||||
when "status"
|
||||
q = q.pending_first
|
||||
when "created_at"
|
||||
q = q.order("created_at desc")
|
||||
when "updated_at"
|
||||
@@ -107,6 +109,8 @@ class TagRelationship < ApplicationRecord
|
||||
q = q.order("antecedent_name asc, consequent_name asc")
|
||||
when "tag_count"
|
||||
q = q.joins(:consequent_tag).order("tags.post_count desc, antecedent_name asc, consequent_name asc")
|
||||
else
|
||||
q = q.apply_default_order(params)
|
||||
end
|
||||
|
||||
q
|
||||
|
||||
@@ -40,7 +40,6 @@ class TagSubscription < ApplicationRecord
|
||||
|
||||
def search(params)
|
||||
q = super
|
||||
params = {} if params.blank?
|
||||
|
||||
if params[:creator_id]
|
||||
q = q.where("creator_id = ?", params[:creator_id].to_i)
|
||||
@@ -56,7 +55,7 @@ class TagSubscription < ApplicationRecord
|
||||
|
||||
q = q.visible_to(CurrentUser.user)
|
||||
|
||||
q
|
||||
q.apply_default_order(params)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -495,7 +495,6 @@ class Upload < ApplicationRecord
|
||||
|
||||
def search(params)
|
||||
q = super
|
||||
return q if params.blank?
|
||||
|
||||
if params[:uploader_id].present?
|
||||
q = q.uploaded_by(params[:uploader_id].to_i)
|
||||
@@ -509,7 +508,7 @@ class Upload < ApplicationRecord
|
||||
q = q.where("source = ?", params[:source])
|
||||
end
|
||||
|
||||
q
|
||||
q.apply_default_order(params)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -815,7 +815,6 @@ class User < ApplicationRecord
|
||||
|
||||
def search(params)
|
||||
q = super
|
||||
return q if params.blank?
|
||||
|
||||
if params[:name].present?
|
||||
q = q.name_matches(params[:name].mb_chars.downcase.strip.tr(" ", "_"))
|
||||
@@ -873,18 +872,14 @@ class User < ApplicationRecord
|
||||
case params[:order]
|
||||
when "name"
|
||||
q = q.order("name")
|
||||
|
||||
when "post_upload_count"
|
||||
q = q.order("post_upload_count desc")
|
||||
|
||||
when "note_count"
|
||||
q = q.order("note_update_count desc")
|
||||
|
||||
when "post_update_count"
|
||||
q = q.order("post_update_count desc")
|
||||
|
||||
else
|
||||
q = q.order("created_at desc")
|
||||
q = q.apply_default_order(params)
|
||||
end
|
||||
|
||||
q
|
||||
|
||||
@@ -45,7 +45,6 @@ class UserFeedback < ApplicationRecord
|
||||
|
||||
def search(params)
|
||||
q = super
|
||||
return q if params.blank?
|
||||
|
||||
if params[:user_id].present?
|
||||
q = q.for_user(params[:user_id].to_i)
|
||||
@@ -67,7 +66,7 @@ class UserFeedback < ApplicationRecord
|
||||
q = q.where("category = ?", params[:category])
|
||||
end
|
||||
|
||||
q
|
||||
q.apply_default_order(params)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -59,9 +59,12 @@ class WikiPage < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def default_order
|
||||
order(updated_at: :desc)
|
||||
end
|
||||
|
||||
def search(params = {})
|
||||
q = super
|
||||
params = {} if params.blank?
|
||||
|
||||
if params[:title].present?
|
||||
q = q.where("title LIKE ? ESCAPE E'\\\\'", params[:title].mb_chars.downcase.tr(" ", "_").to_escaped_for_sql_like)
|
||||
@@ -95,14 +98,12 @@ class WikiPage < ApplicationRecord
|
||||
|
||||
params[:order] ||= params.delete(:sort)
|
||||
case params[:order]
|
||||
when "time"
|
||||
q = q.order("updated_at desc")
|
||||
when "title"
|
||||
q = q.order("title")
|
||||
when "post_count"
|
||||
q = q.includes(:tag).order("tags.post_count desc nulls last").references(:tags)
|
||||
else
|
||||
q = q.order("updated_at desc")
|
||||
q = q.apply_default_order(params)
|
||||
end
|
||||
|
||||
q
|
||||
|
||||
@@ -12,7 +12,6 @@ class WikiPageVersion < ApplicationRecord
|
||||
|
||||
def search(params)
|
||||
q = super
|
||||
return q if params.blank?
|
||||
|
||||
if params[:updater_id].present?
|
||||
q = q.for_user(params[:updater_id].to_i)
|
||||
@@ -22,7 +21,7 @@ class WikiPageVersion < ApplicationRecord
|
||||
q = q.where("wiki_page_id = ?", params[:wiki_page_id].to_i)
|
||||
end
|
||||
|
||||
q
|
||||
q.apply_default_order(params)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user