searchable: don't automatically include id, created_at, updated_at.

Don't make search methods on models call super in order to search
certain default attributes (id, created_at, updated_at). Simplifies some
magic.
This commit is contained in:
evazion
2020-12-16 22:00:22 -06:00
parent b0659eb76c
commit e771c0fca8
45 changed files with 51 additions and 121 deletions

View File

@@ -560,12 +560,10 @@ class User < ApplicationRecord
module SearchMethods
def search(params)
q = super
params = params.dup
params[:name_matches] = params.delete(:name) if params[:name].present?
q = q.search_attributes(params, :name, :level, :post_upload_count, :post_update_count, :note_update_count, :favorite_count)
q = search_attributes(params, :id, :created_at, :updated_at, :name, :level, :post_upload_count, :post_update_count, :note_update_count, :favorite_count)
if params[:name_matches].present?
q = q.where_ilike(:name, normalize_name(params[:name_matches]))