search: refactor to pass in the current user explicitly.

This commit is contained in:
evazion
2022-09-22 04:16:28 -05:00
parent b56b6c554b
commit 88ac91f5f3
82 changed files with 233 additions and 280 deletions

View File

@@ -18,8 +18,8 @@ class Ban < ApplicationRecord
scope :expired, -> { where("bans.created_at + bans.duration <= ?", Time.zone.now) }
scope :active, -> { unexpired }
def self.search(params)
q = search_attributes(params, :id, :created_at, :updated_at, :duration, :reason, :user, :banner)
def self.search(params, current_user)
q = search_attributes(params, [:id, :created_at, :updated_at, :duration, :reason, :user, :banner], current_user: current_user)
q = q.expired if params[:expired].to_s.truthy?
q = q.unexpired if params[:expired].to_s.falsy?