dev_local_scyd
daiao 5 years ago
parent 341c245a40
commit 70c6ae7831

@ -23,16 +23,16 @@ class SubjectsController < ApplicationController
# 最热排序
if reorder == "myshixun_count"
subjects = Subject.joins(:shixuns).where(subjects: {hidden: 0, status: 2})
@subjects = Subject.left_joins(:shixuns).where(subjects: {hidden: 0, status: 2})
.select('subjects.id, subjects.name, subjects.excellent, subjects.stages_count, subjects.status, subjects.homepage_show,
subjects.shixuns_count, subjects.repertoire_id, subjects.updated_at, IFNULL(sum(shixuns.myshixuns_count), 0) myshixuns_count')
.group('subjects.id').order("myshixuns_count desc")
if select
subjects = subjects.where(subjects: {repertoire_id: select})
@subjects = @subjects.where(subjects: {repertoire_id: select})
end
if search
subjects = subjects.where("subjects.name like ?", "%#{search}%")
@subjects = @subjects.where("subjects.name like ?", "%#{search}%")
end
@subjects = subjects.left_joins(:shixuns).select('subjects.id, subjects.name, subjects.excellent, subjects.stages_count, subjects.status, subjects.homepage_show,
subjects.shixuns_count, subjects.repertoire_id, subjects.updated_at, IFNULL(sum(shixuns.myshixuns_count), 0) myshixuns_count')
.group('subjects.id').order("myshixuns_count desc")
else
# 我的路径

Loading…
Cancel
Save