Mercurial > hg > soundsoftware-site
diff app/views/activities/_busy_institution.html.erb @ 1011:f44860e089c5 browsing
Refactor into activities helper
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Mon, 12 Nov 2012 14:38:17 +0000 |
parents | 066b55d7c053 |
children | e816ffefcb71 |
line wrap: on
line diff
--- a/app/views/activities/_busy_institution.html.erb Mon Nov 12 14:22:39 2012 +0000 +++ b/app/views/activities/_busy_institution.html.erb Mon Nov 12 14:38:17 2012 +0000 @@ -1,5 +1,4 @@ <% events = @events_by_day %> -<% max = 5 %> <% if (events.nil?) activity = Redmine::Activity::Fetcher.new(User.current) events = activity.events(Date.today - 14, Date.today + 1) @@ -13,14 +12,7 @@ <ul> <% - authors = events.map { |e| e.event_author unless !e.respond_to?(:event_author) }.compact - institutions = authors.map { |a| a.ssamr_user_detail.institution_name } - insthash = institutions.compact.sort.group_by { |i| i } - insthash = insthash.merge(insthash) { |k,v| v.length } - threshold = insthash.values.sort.last(max).first - busy = insthash.keys.select { |k| insthash[k] >= threshold }.sample(max) - - for institution in busy + for institution in busy_institutions(events, 5) %> <li class="busy">