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.html.erb @ 1009:066b55d7c053
History | View | Annotate | Download (1.5 KB)
| 1 | 1006:4ffe9098c16c | 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 | # Transform events list into hash from project id to number of
|
||
| 17 | # occurrences of project in list (there is surely a tidier way
|
||
| 18 | # to do this, e.g. chunk() in Ruby 1.9 but not in 1.8)
|
||
| 19 | 1009:066b55d7c053 | chris | phash = events.map { |e| e.project unless !e.respond_to?(:project) }.sort.group_by { |p| p.id }
|
| 20 | 1006:4ffe9098c16c | chris | phash = phash.merge(phash) { |k,v| v.length }
|
| 21 | threshold = phash.values.sort.last(max).first
|
||
| 22 | busy = phash.keys.select { |k| phash[k] >= threshold }.sample(max)
|
||
| 23 | |||
| 24 | for id in busy
|
||
| 25 | project = Project.find(id)
|
||
| 26 | %>
|
||
| 27 | |||
| 28 | <li class="busy"> |
||
| 29 | <span class="title"> |
||
| 30 | <% if !project.root? %>
|
||
| 31 | <% project.ancestors.each do |p| %>
|
||
| 32 | <%= h(p) %> » |
||
| 33 | <% end %>
|
||
| 34 | <% end %>
|
||
| 35 | <%= link_to_project project %>
|
||
| 36 | </span>
|
||
| 37 | <% if !project.is_public? %>
|
||
| 38 | <span class="private"><%= l(:field_is_private) %></span> |
||
| 39 | <% end %>
|
||
| 40 | <span class='managers'> |
||
| 41 | <%
|
||
| 42 | u = project.users_by_role
|
||
| 43 | if ! u.empty? %>
|
||
| 44 | (<%=
|
||
| 45 | mgmt_roles = u.keys.select{ |r| r.allowed_to?(:edit_project) }
|
||
| 46 | managers = mgmt_roles.map{ |r| u[r] }.flatten.sort.uniq
|
||
| 47 | managers.map{ |m| m.name }.join(', ')
|
||
| 48 | %>)<% |
||
| 49 | end
|
||
| 50 | %>
|
||
| 51 | </span>
|
||
| 52 | |||
| 53 | <%= render_project_short_description project %>
|
||
| 54 | </li>
|
||
| 55 | |||
| 56 | <% end %>
|
||
| 57 | </ul>
|
||
| 58 | <% end %> |