简化查询匿评数量的代码
This commit is contained in:
parent
3c8f851c37
commit
859889b750
|
@ -140,8 +140,6 @@ module HomeworkAttachHelper
|
||||||
#######################################################
|
#######################################################
|
||||||
def get_student_not_batch_homework_list bid,user
|
def get_student_not_batch_homework_list bid,user
|
||||||
HomeworkAttach.find_by_sql("SELECT * FROM(SELECT homework_attaches.*,
|
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
|
(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
|
FROM homework_attaches
|
||||||
INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id
|
INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id
|
||||||
|
|
Loading…
Reference in New Issue