Reject nil values in working times

This commit is contained in:
Maximilian Grundke
2018-07-13 09:43:06 +02:00
parent 36cbbb7053
commit 815d700481

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