You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/app/queries/admins/school_query.rb

22 lines
527 B

class Admins::SchoolQuery < ApplicationQuery
include CustomSortable
attr_reader :params
sort_columns :users_count, :created_at, default_by: :created_at, default_direction: :desc
def initialize(params)
@params = params
end
def call
schools = School.all
keyword = strip_param(:keyword)
Rails.logger.info("###########{keyword}")
if keyword
schools = schools.where('schools.name LIKE ?', "%#{keyword}%")
end
custom_sort schools, params[:sort_by], params[:sort_direction]
end
end