Revision 1011:f44860e089c5 app/views
| app/views/activities/_busy.html.erb | ||
|---|---|---|
| 1 | 1 |
<% events = @events_by_day %> |
| 2 |
<% max = 5 %> |
|
| 3 | 2 |
<% if (events.nil?) |
| 4 | 3 |
activity = Redmine::Activity::Fetcher.new(User.current) |
| 5 | 4 |
events = activity.events(Date.today - 14, Date.today + 1) |
| ... | ... | |
| 13 | 12 |
<ul> |
| 14 | 13 |
|
| 15 | 14 |
<% |
| 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 |
phash = events.map { |e| e.project unless !e.respond_to?(:project) }.sort.group_by { |p| p.id }
|
|
| 20 |
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) |
|
| 15 |
for project in busy_projects(events, 5) |
|
| 26 | 16 |
%> |
| 27 | 17 |
|
| 28 | 18 |
<li class="busy"> |
| app/views/activities/_busy_institution.html.erb | ||
|---|---|---|
| 1 | 1 |
<% events = @events_by_day %> |
| 2 |
<% max = 5 %> |
|
| 3 | 2 |
<% if (events.nil?) |
| 4 | 3 |
activity = Redmine::Activity::Fetcher.new(User.current) |
| 5 | 4 |
events = activity.events(Date.today - 14, Date.today + 1) |
| ... | ... | |
| 13 | 12 |
<ul> |
| 14 | 13 |
|
| 15 | 14 |
<% |
| 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 |
|
| 15 |
for institution in busy_institutions(events, 5) |
|
| 24 | 16 |
%> |
| 25 | 17 |
|
| 26 | 18 |
<li class="busy"> |
Also available in: Unified diff