chris@1009: <% events = @events_by_day %>
chris@1009: <% max = 5 %>
chris@1009: <% if (events.nil?)
chris@1009: activity = Redmine::Activity::Fetcher.new(User.current)
chris@1009: events = activity.events(Date.today - 14, Date.today + 1)
chris@1009: end
chris@1009: %>
chris@1009:
chris@1009: <% if events.empty? %>
chris@1009:
chris@1009: <% else %>
chris@1009:
chris@1009:
chris@1009:
chris@1009: <%
chris@1009: authors = events.map { |e| e.event_author unless !e.respond_to?(:event_author) }.compact
chris@1009: institutions = authors.map { |a| a.ssamr_user_detail.institution_name }
chris@1009: insthash = institutions.compact.sort.group_by { |i| i }
chris@1009: insthash = insthash.merge(insthash) { |k,v| v.length }
chris@1009: threshold = insthash.values.sort.last(max).first
chris@1009: busy = insthash.keys.select { |k| insthash[k] >= threshold }.sample(max)
chris@1009:
chris@1009: for institution in busy
chris@1009: %>
chris@1009:
chris@1009: -
chris@1009:
chris@1009: <%= link_to h(institution), { :controller => 'activities', :institution => institution } %>
chris@1009:
chris@1009:
chris@1009:
chris@1009: <% end %>
chris@1009:
chris@1009: <% end %>