comparison app/helpers/activities_helper.rb @ 1022:f2ec92061fca browsing

Merge from live branch
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Tue, 13 Nov 2012 10:35:40 +0000
parents b98f60a6d231
children 4d1a31b30987
comparison
equal deleted inserted replaced
1021:967fb7e62b1d 1022:f2ec92061fca
11 busy = phash.keys.select { |k| phash[k] >= threshold }.sample(count) 11 busy = phash.keys.select { |k| phash[k] >= threshold }.sample(count)
12 busy.map { |pid| Project.find(pid) } 12 busy.map { |pid| Project.find(pid) }
13 end 13 end
14 14
15 def busy_institutions(events, count) 15 def busy_institutions(events, count)
16 authors = events.map { |e| e.event_author unless !e.respond_to?(:event_author) }.compact 16 authors = events.map do |e|
17 institutions = authors.map { |a| a.ssamr_user_detail.institution_name } 17 e.event_author unless !e.respond_to?(:event_author)
18 end.compact
19 institutions = authors.map do |a|
20 if a.respond_to?(:ssamr_user_detail) and !a.ssamr_user_detail.nil?
21 a.ssamr_user_detail.institution_name
22 end
23 end
18 insthash = institutions.compact.sort.group_by { |i| i } 24 insthash = institutions.compact.sort.group_by { |i| i }
19 insthash = insthash.merge(insthash) { |k,v| v.length } 25 insthash = insthash.merge(insthash) { |k,v| v.length }
20 threshold = insthash.values.sort.last(count).first 26 threshold = insthash.values.sort.last(count).first
21 insthash.keys.select { |k| insthash[k] >= threshold }.sample(count) 27 insthash.keys.select { |k| insthash[k] >= threshold }.sample(count)
22 end 28 end