changeset 1506:fb773fcf9af8 cannam

Go for unique managers only, not all members unique
author Chris Cannam
date Fri, 21 Mar 2014 13:20:11 +0000
parents d886743cba61
children 9f37f7e39d3c
files app/helpers/projects_helper.rb
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/app/helpers/projects_helper.rb	Fri Mar 21 13:15:42 2014 +0000
+++ b/app/helpers/projects_helper.rb	Fri Mar 21 13:20:11 2014 +0000
@@ -312,15 +312,21 @@
     scores = phash.values.sort
     threshold = scores[scores.length / 2]
     if threshold == 0 then threshold = 1 end
-    uhash = Hash.new
+    mhash = Hash.new
     phash.keys.select do |k|
       if phash[k] < threshold or k.description == "" then
         false
       else
-        uu = k.users
-        novel = (uhash.keys & uu).empty?
-        uu.each { |u| uhash[u] = 1 }
-        novel
+        u = k.users_by_role
+        mgrs = []
+        u.keys.each do |r|
+          if r.allowed_to?(:edit_project)
+            mgrs << u[r]
+          end
+        end
+        novel = (mhash.keys & mgrs).empty?
+        mgrs.each { |m| mhash[m] = 1 }
+        novel and not mgrs.empty?
       end
     end.sample(count)
   end