Mercurial > hg > soundsoftware-site
annotate app/views/activities/_busy.html.erb @ 1006:4ffe9098c16c browsing
Busy-projects partial, etc
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Fri, 09 Nov 2012 17:41:04 +0000 |
parents | |
children | 066b55d7c053 |
rev | line source |
---|---|
chris@1006 | 1 <% events = @events_by_day %> |
chris@1006 | 2 <% max = 5 %> |
chris@1006 | 3 <% if (events.nil?) |
chris@1006 | 4 activity = Redmine::Activity::Fetcher.new(User.current) |
chris@1006 | 5 events = activity.events(Date.today - 14, Date.today + 1) |
chris@1006 | 6 end |
chris@1006 | 7 %> |
chris@1006 | 8 |
chris@1006 | 9 <% if events.empty? %> |
chris@1006 | 10 |
chris@1006 | 11 <% else %> |
chris@1006 | 12 |
chris@1006 | 13 <ul> |
chris@1006 | 14 |
chris@1006 | 15 <% |
chris@1006 | 16 # Transform events list into hash from project id to number of |
chris@1006 | 17 # occurrences of project in list (there is surely a tidier way |
chris@1006 | 18 # to do this, e.g. chunk() in Ruby 1.9 but not in 1.8) |
chris@1006 | 19 phash = events.map { |e| e.project }.sort.group_by { |p| p.id } |
chris@1006 | 20 phash = phash.merge(phash) { |k,v| v.length } |
chris@1006 | 21 threshold = phash.values.sort.last(max).first |
chris@1006 | 22 busy = phash.keys.select { |k| phash[k] >= threshold }.sample(max) |
chris@1006 | 23 |
chris@1006 | 24 for id in busy |
chris@1006 | 25 project = Project.find(id) |
chris@1006 | 26 %> |
chris@1006 | 27 |
chris@1006 | 28 <li class="busy"> |
chris@1006 | 29 <span class="title"> |
chris@1006 | 30 <% if !project.root? %> |
chris@1006 | 31 <% project.ancestors.each do |p| %> |
chris@1006 | 32 <%= h(p) %> » |
chris@1006 | 33 <% end %> |
chris@1006 | 34 <% end %> |
chris@1006 | 35 <%= link_to_project project %> |
chris@1006 | 36 </span> |
chris@1006 | 37 <% if !project.is_public? %> |
chris@1006 | 38 <span class="private"><%= l(:field_is_private) %></span> |
chris@1006 | 39 <% end %> |
chris@1006 | 40 <span class='managers'> |
chris@1006 | 41 <% |
chris@1006 | 42 u = project.users_by_role |
chris@1006 | 43 if ! u.empty? %> |
chris@1006 | 44 (<%= |
chris@1006 | 45 mgmt_roles = u.keys.select{ |r| r.allowed_to?(:edit_project) } |
chris@1006 | 46 managers = mgmt_roles.map{ |r| u[r] }.flatten.sort.uniq |
chris@1006 | 47 managers.map{ |m| m.name }.join(', ') |
chris@1006 | 48 %>)<% |
chris@1006 | 49 end |
chris@1006 | 50 %> |
chris@1006 | 51 </span> |
chris@1006 | 52 |
chris@1006 | 53 <%= render_project_short_description project %> |
chris@1006 | 54 </li> |
chris@1006 | 55 |
chris@1006 | 56 <% end %> |
chris@1006 | 57 </ul> |
chris@1006 | 58 <% end %> |