Merge pull request #186 from openHPI/fix/exercise-anomaly-detection-nil-values

Reject nil values in working times
This commit is contained in:
rteusner
2018-07-13 23:23:35 +02:00
committed by GitHub

View File

@ -71,10 +71,9 @@ namespace :detect_exercise_anomalies do
end
def find_anomalies(collection)
working_times = collect_working_times(collection)
values = working_times.values.reject {|value| value.nil?}
if values.size > 0
average = values.reduce(:+) / values.size
working_times = collect_working_times(collection).reject {|_, value| value.nil?}
if working_times.size > 0
average = working_times.reduce(:+) / working_times.size
return working_times.select do |_, working_time|
working_time > average * MAX_TIME_FACTOR or working_time < average * MIN_TIME_FACTOR
end