Mercurial > hg > soundsoftware-site
comparison app/helpers/projects_helper.rb @ 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 | 523f55b47b98 |
| children | 9f37f7e39d3c |
comparison
equal
deleted
inserted
replaced
| 1505:d886743cba61 | 1506:fb773fcf9af8 |
|---|---|
| 310 def varied_mature_projects(count) | 310 def varied_mature_projects(count) |
| 311 phash = top_level_maturity_scores | 311 phash = top_level_maturity_scores |
| 312 scores = phash.values.sort | 312 scores = phash.values.sort |
| 313 threshold = scores[scores.length / 2] | 313 threshold = scores[scores.length / 2] |
| 314 if threshold == 0 then threshold = 1 end | 314 if threshold == 0 then threshold = 1 end |
| 315 uhash = Hash.new | 315 mhash = Hash.new |
| 316 phash.keys.select do |k| | 316 phash.keys.select do |k| |
| 317 if phash[k] < threshold or k.description == "" then | 317 if phash[k] < threshold or k.description == "" then |
| 318 false | 318 false |
| 319 else | 319 else |
| 320 uu = k.users | 320 u = k.users_by_role |
| 321 novel = (uhash.keys & uu).empty? | 321 mgrs = [] |
| 322 uu.each { |u| uhash[u] = 1 } | 322 u.keys.each do |r| |
| 323 novel | 323 if r.allowed_to?(:edit_project) |
| 324 mgrs << u[r] | |
| 325 end | |
| 326 end | |
| 327 novel = (mhash.keys & mgrs).empty? | |
| 328 mgrs.each { |m| mhash[m] = 1 } | |
| 329 novel and not mgrs.empty? | |
| 324 end | 330 end |
| 325 end.sample(count) | 331 end.sample(count) |
| 326 end | 332 end |
| 327 | 333 |
| 328 end | 334 end |
