# HG changeset patch # User Chris Cannam # Date 1395408011 0 # Node ID fb773fcf9af871fed622468fc2f73dea0089a9bf # Parent d886743cba619c3f50c03a3d6c86e0978a9fdc59 Go for unique managers only, not all members unique diff -r d886743cba61 -r fb773fcf9af8 app/helpers/projects_helper.rb --- 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