|
|
|
@ -24,11 +24,11 @@ class SubjectsController < ApplicationController
|
|
|
|
|
# 最热排序
|
|
|
|
|
if reorder == "myshixun_count"
|
|
|
|
|
if current_laboratory.main_site?
|
|
|
|
|
not_subject_ids = Subject.joins(:laboratory_subjects).where("laboratory_subjects.laboratory_id != #{current_laboratory.id}")
|
|
|
|
|
not_subject_ids = Subject.joins(:laboratory_subjects).where("laboratory_subjects.laboratory_id != #{current_laboratory.id}").pluck(:id)
|
|
|
|
|
not_subject_ids = not_subject_ids.length > 0 ? "(" + not_subject_ids.join(",") + ")" : "(-1)"
|
|
|
|
|
laboratory_join = " AND subjects.id not in #{not_subject_ids} "
|
|
|
|
|
else
|
|
|
|
|
subject_ids = Subject.joins(:laboratory_subjects).where(laboratory_subjects: { laboratory_id: current_laboratory.id })
|
|
|
|
|
subject_ids = Subject.joins(:laboratory_subjects).where(laboratory_subjects: { laboratory_id: current_laboratory.id }).pluck(:id)
|
|
|
|
|
subject_ids = subject_ids.length > 0 ? "(" + subject_ids.join(",") + ")" : "(-1)"
|
|
|
|
|
laboratory_join = " AND subjects.id in #{subject_ids} "
|
|
|
|
|
end
|
|
|
|
|