changeset 1228:44475ccf56d3 cannam

Merge from branch "live"
author Chris Cannam
date Tue, 12 Mar 2013 15:44:39 +0000
parents 30c444ea1338 (current diff) eb168c1e9553 (diff)
children 96790506f247 a778eeeeec77
files
diffstat 4 files changed, 30 insertions(+), 61 deletions(-) [+]
line wrap: on
line diff
--- a/app/controllers/my_controller.rb	Tue Mar 12 15:15:18 2013 +0000
+++ b/app/controllers/my_controller.rb	Tue Mar 12 15:44:39 2013 +0000
@@ -38,7 +38,7 @@
            }.merge(Redmine::Views::MyPage::Block.additional_blocks).freeze
 
   DEFAULT_LAYOUT = {  'left' => ['myprojects', 'activitymyprojects'], 
-                      'right' => ['tipoftheday', 'colleagues', 'issueswatched'] 
+                      'right' => ['tipoftheday', 'issueswatched'] 
                    }.freeze
 
   verify :xhr => true,
--- a/app/helpers/activities_helper.rb	Tue Mar 12 15:15:18 2013 +0000
+++ b/app/helpers/activities_helper.rb	Tue Mar 12 15:44:39 2013 +0000
@@ -45,7 +45,7 @@
 
   def projects_by_activity(user, count)
 
-    # Return up to count of the user's projects ordered by that user's
+    # Return up to count of the user's project ids ordered by that user's
     # recent activity, omitting any projects for which no activity
     # occurred in the recent past and any projects not visible to
     # the current user
@@ -67,37 +67,52 @@
 
     start = Time.now
 
+    my_inst = ""
+    if ! User.current.ssamr_user_detail.nil?
+      my_inst = User.current.ssamr_user_detail.institution_name
+    end
+
+    actives = Hash.new
     for c in colleagues
       u = User.find_by_id(c)
       active_projects = projects_by_activity(u, 3)
       if !active_projects.empty?
-        s << "<dl>"
+        actives[c] = active_projects
+      end
+    end
+
+    if actives.empty?
+      l(:label_no_active_colleagues)
+    else
+
+      s << "<dl>"
+      for c in actives.keys.sample(10)
+        u = User.find_by_id(c)
         s << "<dt>"
         s << avatar(u, :size => '24')
         s << "<span class='user'>"
         s << h(u.name)
         s << "</span>"
         if !u.ssamr_user_detail.nil?
-          s << " - <span class='institution'>"
-          s << h(u.ssamr_user_detail.institution_name)
-          s << "</span>"
+          inst = u.ssamr_user_detail.institution_name
+          if inst != "" and inst != my_inst
+            s << " - <span class='institution'>"
+            s << h(u.ssamr_user_detail.institution_name)
+            s << "</span>"
+          end
         end
         s << "</dt>"
         s << "<dd>"
         s << "<span class='active'>"
-        s << (active_projects.map { |p| link_to_project(p) }.join ", ")
+        s << (actives[c].map { |p| link_to_project(p) }.join ", ")
         s << "</span>"
-        s << "</dl>"
       end
-    end
+      s << "</dl>"
 
-    finish = Time.now
-    logger.info "render_active_colleagues: took #{finish-start}"
+      finish = Time.now
+      logger.info "render_active_colleagues: took #{finish-start}"
     
-    if s != ""
       s
-    else
-      l(:label_no_active_colleagues)
     end
   end
 
--- a/app/helpers/my_helper.rb	Tue Mar 12 15:15:18 2013 +0000
+++ b/app/helpers/my_helper.rb	Tue Mar 12 15:44:39 2013 +0000
@@ -25,50 +25,4 @@
     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 << "<div class='active-person'>"
-        s << avatar(u, :size => '24')
-        s << "<span class='user'>"
-        s << h(u.name)
-        s << "</span>"
-        if !u.ssamr_user_detail.nil?
-          inst = u.ssamr_user_detail.institution_name
-          if inst != "" and inst != my_inst
-            s << " - <span class='institution'>"
-            s << h(inst)
-            s << "</span>"
-          end
-        end
-        s << "<br>"
-        s << "<span class='active'>"
-        s << (active_projects.map { |p| link_to_project(p) }.join ", ")
-        s << "</span>"
-        s << "</div>"
-      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
--- a/app/views/my/blocks/_colleagues.html.erb	Tue Mar 12 15:15:18 2013 +0000
+++ b/app/views/my/blocks/_colleagues.html.erb	Tue Mar 12 15:44:39 2013 +0000
@@ -1,5 +1,5 @@
 
-<% colleagues = all_colleagues_of(@user).sample(10) %>
+<% colleagues = all_colleagues_of(@user) %>
 
 <% if !colleagues.empty? %>
 <div id="activity">