|
|
|
@ -40,11 +40,21 @@ class SearchService < ApplicationService
|
|
|
|
|
def extra_options
|
|
|
|
|
case params[:type].to_s.strip
|
|
|
|
|
when 'shixun' then
|
|
|
|
|
shixun_ids = Laboratory.current.shixuns.pluck(:id)
|
|
|
|
|
Laboratory.current.main_site? ? {} : { where: { id: shixun_ids } }
|
|
|
|
|
if Laboratory.current.main_site?
|
|
|
|
|
not_shixun_ids = Shixun.joins(:laboratory_shixuns).where("laboratory_shixuns.laboratory_id != #{Laboratory.current.id}")
|
|
|
|
|
shixun_ids = Shixun.where.not(id: not_shixun_ids).pluck(:id)
|
|
|
|
|
else
|
|
|
|
|
shixun_ids = Laboratory.current.shixuns.pluck(:id)
|
|
|
|
|
end
|
|
|
|
|
{ where: { id: shixun_ids } }
|
|
|
|
|
when 'subject' then
|
|
|
|
|
subject_ids = Laboratory.current.subjects.pluck(:id)
|
|
|
|
|
Laboratory.current.main_site? ? {} : { where: { id: subject_ids } }
|
|
|
|
|
if Laboratory.current.main_site?
|
|
|
|
|
not_subject_ids = Subject.joins(:laboratory_subjects).where("laboratory_subjects.laboratory_id != #{Laboratory.current.id}")
|
|
|
|
|
subject_ids = Subject.where.not(id: not_subject_ids).pluck(:id)
|
|
|
|
|
else
|
|
|
|
|
subject_ids = Laboratory.current.subjects.pluck(:id)
|
|
|
|
|
end
|
|
|
|
|
{ where: { id: subject_ids } }
|
|
|
|
|
when 'course' then
|
|
|
|
|
{ where: { laboratory_id: Laboratory.current.id } }
|
|
|
|
|
else
|
|
|
|
|