Mercurial > hg > soundsoftware-site
changeset 1013:b98f60a6d231 live
Avoid crashing out with weird event types that don't give us a proper author record
author | Chris Cannam |
---|---|
date | Mon, 12 Nov 2012 14:55:11 +0000 |
parents | bbca6f4eebc7 |
children | e3f78fa30a36 |
files | app/helpers/activities_helper.rb |
diffstat | 1 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/app/helpers/activities_helper.rb Mon Nov 12 14:40:09 2012 +0000 +++ b/app/helpers/activities_helper.rb Mon Nov 12 14:55:11 2012 +0000 @@ -13,8 +13,14 @@ end def busy_institutions(events, count) - authors = events.map { |e| e.event_author unless !e.respond_to?(:event_author) }.compact - institutions = authors.map { |a| a.ssamr_user_detail.institution_name } + authors = events.map do |e| + e.event_author unless !e.respond_to?(:event_author) + end.compact + institutions = authors.map do |a| + if a.respond_to?(:ssamr_user_detail) and !a.ssamr_user_detail.nil? + a.ssamr_user_detail.institution_name + end + end insthash = institutions.compact.sort.group_by { |i| i } insthash = insthash.merge(insthash) { |k,v| v.length } threshold = insthash.values.sort.last(count).first