Mercurial > hg > soundsoftware-site
changeset 1508:a983b92b2fc1 live
Merge from branch cannam
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Fri, 21 Mar 2014 13:37:49 +0000 |
parents | 0fcf95cec435 (current diff) 9f37f7e39d3c (diff) |
children | fae089e1f1a3 |
files | |
diffstat | 1 files changed, 12 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/app/helpers/projects_helper.rb Fri Mar 21 13:14:05 2014 +0000 +++ b/app/helpers/projects_helper.rb Fri Mar 21 13:37:49 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 - phash.keys.select do |k| + mhash = Hash.new + phash.keys.shuffle.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) + u[r].each { |m| mgrs << m } + end + end + novel = (mhash.keys & mgrs).empty? + mgrs.each { |m| mhash[m] = 1 } + novel and not mgrs.empty? end end.sample(count) end