@ -17,7 +17,7 @@ namespace :competition do
# =========== Shixun ===========
shixuns = Shixun . where ( user_id : team_user_ids , status : 2 )
. where ( 'shixuns.created_at > ? && shixuns.created_at <= ?' , Time . parse ( '2018-06-01' ) , competition . end_time )
. where ( 'shixuns.created_at > ? && shixuns.created_at <= ?' , Time . parse ( '2018-06-01' ) , Time . now )
shixuns = shixuns . joins ( 'left join shixuns forked_shixuns on forked_shixuns.fork_from = shixuns.id and forked_shixuns.status = 2' )
shixuns = shixuns . select ( 'shixuns.id, shixuns.identifier, shixuns.user_id, shixuns.myshixuns_count, shixuns.name, shixuns.fork_from, sum(forked_shixuns.myshixuns_count) forked_myshixun_count' )
shixuns = shixuns . group ( 'shixuns.id' ) . order ( 'shixuns.myshixuns_count desc' ) . includes ( :creator )
@ -82,7 +82,7 @@ namespace :competition do
. select ( 'sum(compelete_status !=0 ) as finish, count(*) as total' )
. 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 ( 'courses.created_at <= ?' , Time . now )
. where ( " ( #{ student_count_subquery } ) >= 3 " )
. where ( " exists(select 1 from homework_commons hcs where hcs.course_id = courses.id and hcs.publish_time is not null and hcs.publish_time < NOW() and hcs.homework_type = 4 and exists( #{ subquery } )) " )
. joins ( 'join course_members on course_members.course_id = courses.id and course_members.role in (1,2,3)' )