To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / app / views / activities / _busy_institution.html.erb @ 1009:066b55d7c053
History | View | Annotate | Download (921 Bytes)
| 1 | 1009:066b55d7c053 | chris | <% 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 %> |