优化课程首页效率

This commit is contained in:
sw 2014-08-11 15:07:56 +08:00
parent f7635370d7
commit 33855f721d
1 changed files with 2 additions and 2 deletions

View File

@ -233,10 +233,10 @@ module WelcomeHelper
#sort_project_by_hot_rails 1, 'course_ac_para DESC', limit
time_now = Time.new.strftime("%Y")
if school_id
courses = Course.includes(:school).visible.joins(:course_status).where("#{Course.table_name}.created_at like '%#{time_now}%' and #{Course.table_name}.school_id <>
courses = Course.includes(:school, :members).visible.joins(:course_status).where("#{Course.table_name}.created_at like '%#{time_now}%' and #{Course.table_name}.school_id <>
?", school_id).order("course_ac_para DESC").limit(limit).all
else
courses = Course.includes(:school).visible.joins(:course_status).where("#{Course.table_name}.created_at like '%#{time_now}%' and #{Course.table_name}.school_id is not NULL
courses = Course.includes(:school, :members).visible.joins(:course_status).where("#{Course.table_name}.created_at like '%#{time_now}%' and #{Course.table_name}.school_id is not NULL
").order("course_ac_para DESC").limit(limit).all
end
courses