# HG changeset patch # User Chris Cannam # Date 1358783328 0 # Node ID 4d1a31b309877981ee80cb46c89e81950aba6108 # Parent 54a92921cf091c2d811123c07c5fdaab453a330c Remove nil projects before sorting diff -r 54a92921cf09 -r 4d1a31b30987 app/helpers/activities_helper.rb --- a/app/helpers/activities_helper.rb Mon Jan 21 14:18:00 2013 +0000 +++ b/app/helpers/activities_helper.rb Mon Jan 21 15:48:48 2013 +0000 @@ -5,7 +5,9 @@ # Transform events list into hash from project id to number of # occurrences of project in list (there is surely a tidier way # to do this, e.g. chunk() in Ruby 1.9 but not in 1.8) - phash = events.map { |e| e.project unless !e.respond_to?(:project) }.sort.group_by { |p| p.id } + phash = events.map do |e| + e.project unless !e.respond_to?(:project) + end.select { |p| !p.nil? }.sort.group_by { |p| p.id } phash = phash.merge(phash) { |k,v| v.length } threshold = phash.values.sort.last(count).first busy = phash.keys.select { |k| phash[k] >= threshold }.sample(count)