简化查询匿评数量的代码

This commit is contained in:
sw 2015-02-06 11:27:37 +08:00
parent 3c8f851c37
commit 859889b750
1 changed files with 0 additions and 2 deletions

View File

@ -140,8 +140,6 @@ module HomeworkAttachHelper
#######################################################
def get_student_not_batch_homework_list bid,user
HomeworkAttach.find_by_sql("SELECT * FROM(SELECT homework_attaches.*,
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1) AS t_score,
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score,
(SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{user.id} AND is_teacher_score = 0) AS m_score
FROM homework_attaches
INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id