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

Fix/exercise anomaly detection nil values
This commit is contained in:
rteusner
2018-07-25 13:57:08 +02:00
committed by GitHub

View File

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