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.
36 lines
911 B
36 lines
911 B
|
|
module Api |
|
class DoctrinesController < BaseController |
|
authorize_resource :doctrine, class: "Doctrine", only: %i[index] |
|
|
|
def index |
|
search = doctrine_search(search_params) |
|
|
|
@doctrines = search.results |
|
|
|
respond_with @doctrines |
|
end |
|
|
|
private |
|
|
|
def doctrine_search(search_params) |
|
search = Sunspot.search(Doctrine) do |
|
|
|
with(:subject_ids).any_of(search_params[:subject_ids]) if search_params[:subject_ids].present? |
|
|
|
with(:user_ids).any_of(search_params[:user_ids]) if search_params[:user_ids].present? |
|
|
|
if search_params[:created_at].present? |
|
with(:created_at).between(Date.parse(search_params[:created_at]..Time.zone.today.to_date) |
|
end |
|
end |
|
|
|
search |
|
end |
|
|
|
def search_params |
|
params.permit(subject_ids: [], user_ids: [], :created_at) |
|
end |
|
end |
|
end |
|
|