From 6822506bdf4200d12d6e62ec6a8b26103110fa85 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Fri, 2 Aug 2019 11:20:56 +0800 Subject: [PATCH] fix --- app/controllers/competition_teams_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/competition_teams_controller.rb b/app/controllers/competition_teams_controller.rb index c6b80e73..e559253b 100644 --- a/app/controllers/competition_teams_controller.rb +++ b/app/controllers/competition_teams_controller.rb @@ -44,7 +44,7 @@ class CompetitionTeamsController < ApplicationController student_count_subquery = CourseMember.where('course_id = courses.id AND role = 5').select('count(*)').to_sql subquery = StudentWork.where('homework_common_id = hcs.id') .select('sum(compelete_status !=0 ) as finish, count(*) as total') - .having('finish > (total / 2)').to_sql + .having('total != 0 and finish >= (total / 2)').to_sql course_ids = Course.where('courses.created_at > ?', Time.parse('2018-06-01')) .where('courses.created_at <= ?', @competition.end_time) .where("(#{student_count_subquery}) >= 10") @@ -367,7 +367,7 @@ class CompetitionTeamsController < ApplicationController def get_valid_course_count(ids) percentage_sql = StudentWork.where('homework_common_id = homework_commons.id and homework_commons.publish_time is not null and homework_commons.publish_time < NOW()') .select('sum(compelete_status !=0 ) as finish, count(*) as total') - .having('total != 0 && finish > (total / 2)').to_sql + .having('total != 0 and finish >= (total / 2)').to_sql Course.joins(shixun_homework_commons: :homework_commons_shixuns) .where('shixun_id in (?)', ids) @@ -378,7 +378,7 @@ class CompetitionTeamsController < ApplicationController def get_valid_shixun_count(ids) percentage_sql = StudentWork.where('homework_common_id = homework_commons.id and homework_commons.publish_time is not null and homework_commons.publish_time < NOW()') .select('sum(compelete_status !=0 ) as finish, count(*) as total') - .having('finish > (total / 2)').to_sql + .having('total != 0 and finish >= (total / 2)').to_sql Shixun.joins(homework_commons_shixuns: :homework_common) .where(homework_commons: { homework_type: 3 }) .where('course_id in (?)', ids)