# HG changeset patch
# User Chris Cannam
# Date 1363101247 0
# Node ID edf7563e26536d6753a087b8767772f5a8761809
# Parent 31aee88c279bbef624dcd515027e22fcff01586f# Parent 30c444ea13383c6a2a1df865b83401f0120fb281
Merge from branch "cannam"
diff -r 31aee88c279b -r edf7563e2653 app/controllers/my_controller.rb
--- a/app/controllers/my_controller.rb Tue Mar 12 13:36:57 2013 +0000
+++ b/app/controllers/my_controller.rb Tue Mar 12 15:14:07 2013 +0000
@@ -38,7 +38,7 @@
}.merge(Redmine::Views::MyPage::Block.additional_blocks).freeze
DEFAULT_LAYOUT = { 'left' => ['myprojects', 'activitymyprojects'],
- 'right' => ['tipoftheday', 'issueswatched']
+ 'right' => ['tipoftheday', 'colleagues', 'issueswatched']
}.freeze
verify :xhr => true,
diff -r 31aee88c279b -r edf7563e2653 app/helpers/activities_helper.rb
--- a/app/helpers/activities_helper.rb Tue Mar 12 13:36:57 2013 +0000
+++ b/app/helpers/activities_helper.rb Tue Mar 12 15:14:07 2013 +0000
@@ -51,6 +51,10 @@
# the current user
activity = Redmine::Activity::Fetcher.new(User.current, :author => user)
+
+ # Limit scope so as to exclude issues (which non-members can add)
+ activity.scope = [ "changesets", "files", "documents", "news", "wiki_edits", "messages", "time_entries", "publications" ]
+
days = Setting.activity_days_default.to_i
events = activity.events(Date.today - days, Date.today + 1)
projhash = project_activity_on_events(events)
@@ -61,11 +65,14 @@
s = ""
+ start = Time.now
+
for c in colleagues
u = User.find_by_id(c)
active_projects = projects_by_activity(u, 3)
if !active_projects.empty?
- s << "
"
+ s << "
"
+ s << "- "
s << avatar(u, :size => '24')
s << ""
s << h(u.name)
@@ -75,13 +82,17 @@
s << h(u.ssamr_user_detail.institution_name)
s << ""
end
- s << "
"
+ s << " "
+ s << "- "
s << ""
s << (active_projects.map { |p| link_to_project(p) }.join ", ")
s << ""
- s << "
"
+ s << ""
end
end
+
+ finish = Time.now
+ logger.info "render_active_colleagues: took #{finish-start}"
if s != ""
s
diff -r 31aee88c279b -r edf7563e2653 app/helpers/my_helper.rb
--- a/app/helpers/my_helper.rb Tue Mar 12 13:36:57 2013 +0000
+++ b/app/helpers/my_helper.rb Tue Mar 12 15:14:07 2013 +0000
@@ -19,10 +19,56 @@
module MyHelper
-def all_colleagues_of(user)
- # Return a list of all user ids who have worked with the given user
- # (on projects that are visible to the current user)
- user.projects.select { |p| p.visible? }.map { |p| p.members.map { |m| m.user_id } }.flatten.sort.uniq.reject { |i| user.id == i }
-end
+ def all_colleagues_of(user)
+ # Return a list of all user ids who have worked with the given user
+ # (on projects that are visible to the current user)
+ user.projects.select { |p| p.visible? }.map { |p| p.members.map { |m| m.user_id } }.flatten.sort.uniq.reject { |i| user.id == i }
+ end
+
+ def render_active_colleagues(colleagues)
+
+ s = ""
+
+ start = Time.now
+
+ my_inst = ""
+ if ! User.current.ssamr_user_detail.nil?
+ my_inst = User.current.ssamr_user_detail.institution_name
+ end
+
+ for c in colleagues
+ u = User.find_by_id(c)
+ active_projects = projects_by_activity(u, 3)
+ if !active_projects.empty?
+ s << ""
+ s << avatar(u, :size => '24')
+ s << ""
+ s << h(u.name)
+ s << ""
+ if !u.ssamr_user_detail.nil?
+ inst = u.ssamr_user_detail.institution_name
+ if inst != "" and inst != my_inst
+ s << " - "
+ s << h(inst)
+ s << ""
+ end
+ end
+ s << "
"
+ s << ""
+ s << (active_projects.map { |p| link_to_project(p) }.join ", ")
+ s << ""
+ s << "
"
+ end
+ end
+
+ finish = Time.now
+ logger.info "render_active_colleagues: took #{finish-start}"
+
+ if s != ""
+ s
+ else
+ l(:label_no_active_colleagues)
+ end
+ end
end
diff -r 31aee88c279b -r edf7563e2653 app/views/my/blocks/_colleagues.html.erb
--- a/app/views/my/blocks/_colleagues.html.erb Tue Mar 12 13:36:57 2013 +0000
+++ b/app/views/my/blocks/_colleagues.html.erb Tue Mar 12 15:14:07 2013 +0000
@@ -1,11 +1,13 @@
-<% colleagues = all_colleagues_of(@user) %>
+<% colleagues = all_colleagues_of(@user).sample(10) %>
<% if !colleagues.empty? %>
+
<%=l(:label_my_colleagues)%>
-
+
<%= render_active_colleagues(colleagues) %>
+
<% end %>