Update exercise anomaly detection to work on new schema
This commit is contained in:
@ -49,14 +49,14 @@ namespace :detect_exercise_anomalies do
|
|||||||
def get_collections(number_of_exercises, number_of_solutions)
|
def get_collections(number_of_exercises, number_of_solutions)
|
||||||
ExerciseCollection
|
ExerciseCollection
|
||||||
.where(:use_anomaly_detection => true)
|
.where(:use_anomaly_detection => true)
|
||||||
.joins("join exercise_collections_exercises ece on exercise_collections.id = ece.exercise_collection_id
|
.joins("join exercise_collection_items eci on exercise_collections.id = eci.exercise_collection_id
|
||||||
join
|
join
|
||||||
(select e.id
|
(select e.id
|
||||||
from exercises e
|
from exercises e
|
||||||
join submissions s on s.exercise_id = e.id
|
join submissions s on s.exercise_id = e.id
|
||||||
group by e.id
|
group by e.id
|
||||||
having count(s.user_id) > #{ExerciseCollection.sanitize(number_of_solutions)}
|
having count(s.user_id) > #{ExerciseCollection.sanitize(number_of_solutions)}
|
||||||
) as exercises_with_submissions on exercises_with_submissions.id = ece.exercise_id")
|
) as exercises_with_submissions on exercises_with_submissions.id = eci.exercise_id")
|
||||||
.group('exercise_collections.id')
|
.group('exercise_collections.id')
|
||||||
.having('count(exercises_with_submissions.id) > ?', number_of_exercises)
|
.having('count(exercises_with_submissions.id) > ?', number_of_exercises)
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user