comparison app/views/activities/_busy_institution.html.erb @ 1009:066b55d7c053 browsing

Add busy institutions list
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Mon, 12 Nov 2012 13:34:32 +0000
parents
children f44860e089c5
comparison
equal deleted inserted replaced
1008:8196ed891e54 1009:066b55d7c053
1 <% events = @events_by_day %>
2 <% max = 5 %>
3 <% if (events.nil?)
4 activity = Redmine::Activity::Fetcher.new(User.current)
5 events = activity.events(Date.today - 14, Date.today + 1)
6 end
7 %>
8
9 <% if events.empty? %>
10
11 <% else %>
12
13 <ul>
14
15 <%
16 authors = events.map { |e| e.event_author unless !e.respond_to?(:event_author) }.compact
17 institutions = authors.map { |a| a.ssamr_user_detail.institution_name }
18 insthash = institutions.compact.sort.group_by { |i| i }
19 insthash = insthash.merge(insthash) { |k,v| v.length }
20 threshold = insthash.values.sort.last(max).first
21 busy = insthash.keys.select { |k| insthash[k] >= threshold }.sample(max)
22
23 for institution in busy
24 %>
25
26 <li class="busy">
27 <span class="title">
28 <%= link_to h(institution), { :controller => 'activities', :institution => institution } %>
29 </span>
30 </li>
31
32 <% end %>
33 </ul>
34 <% end %>