Revision 1009:066b55d7c053 app/views/activities
| app/views/activities/_busy.html.erb | ||
|---|---|---|
| 16 | 16 |
# Transform events list into hash from project id to number of |
| 17 | 17 |
# occurrences of project in list (there is surely a tidier way |
| 18 | 18 |
# to do this, e.g. chunk() in Ruby 1.9 but not in 1.8) |
| 19 |
phash = events.map { |e| e.project }.sort.group_by { |p| p.id }
|
|
| 19 |
phash = events.map { |e| e.project unless !e.respond_to?(:project) }.sort.group_by { |p| p.id }
|
|
| 20 | 20 |
phash = phash.merge(phash) { |k,v| v.length }
|
| 21 | 21 |
threshold = phash.values.sort.last(max).first |
| 22 | 22 |
busy = phash.keys.select { |k| phash[k] >= threshold }.sample(max)
|
| app/views/activities/_busy_institution.html.erb | ||
|---|---|---|
| 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 %> |
|
| app/views/activities/index.html.erb | ||
|---|---|---|
| 1 |
<h2><%= @author.nil? ? l(:label_activity) : l(:label_user_activity, link_to_user(@author)) %></h2> |
|
| 1 |
<h2><%= |
|
| 2 |
if @author.nil? |
|
| 3 |
if @institution_name.blank? |
|
| 4 |
l(:label_activity) |
|
| 5 |
else |
|
| 6 |
l(:label_institution_activity, h(@institution_name)) |
|
| 7 |
end |
|
| 8 |
else |
|
| 9 |
l(:label_user_activity, link_to_user(@author)) |
|
| 10 |
end |
|
| 11 |
%></h2> |
|
| 2 | 12 |
<p class="subtitle"><%= l(:label_date_from_to, :start => format_date(@date_to - @days), :end => format_date(@date_to-1)) %></p> |
| 3 | 13 |
|
| 4 | 14 |
<div id="activity"> |
Also available in: Unified diff