comparison app/helpers/projects_helper.rb @ 1519:afce8026aaeb redmine-2.4-integration

Merge from branch "live"
author Chris Cannam
date Tue, 09 Sep 2014 09:34:53 +0100
parents c86dacc2ef0a 9f37f7e39d3c
children a1bdbf8a87d5
comparison
equal deleted inserted replaced
1518:2e8063097240 1519:afce8026aaeb
277 then project.publications.count else 0 end 277 then project.publications.count else 0 end
278 Math.log(1 + nr_changes) + 278 Math.log(1 + nr_changes) +
279 Math.log(1 + nr_downloadables) + 279 Math.log(1 + nr_downloadables) +
280 Math.log(1 + nr_downloads) + 280 Math.log(1 + nr_downloads) +
281 Math.sqrt(nr_members > 1 ? (nr_members - 1) : 0) + 281 Math.sqrt(nr_members > 1 ? (nr_members - 1) : 0) +
282 Math.sqrt(nr_publications) 282 Math.sqrt(nr_publications * 2)
283 end 283 end
284 284
285 def all_maturity_scores() 285 def all_maturity_scores()
286 phash = Hash.new 286 phash = Hash.new
287 pp = Project.visible(User.anonymous) 287 pp = Project.visible(User.anonymous)
288 pp.each do |p|
289 phash[p] = score_maturity p
290 end
291 phash
292 end
293
294 def top_level_maturity_scores()
295 phash = Hash.new
296 pp = Project.visible_roots(User.anonymous)
288 pp.each do |p| 297 pp.each do |p|
289 phash[p] = score_maturity p 298 phash[p] = score_maturity p
290 end 299 end
291 phash 300 phash
292 end 301 end
296 scores = phash.values.sort 305 scores = phash.values.sort
297 threshold = scores[scores.length / 2] 306 threshold = scores[scores.length / 2]
298 if threshold == 0 then threshold = 1 end 307 if threshold == 0 then threshold = 1 end
299 phash.keys.select { |k| phash[k] > threshold }.sample(count) 308 phash.keys.select { |k| phash[k] > threshold }.sample(count)
300 end 309 end
310
311 def varied_mature_projects(count)
312 phash = top_level_maturity_scores
313 scores = phash.values.sort
314 threshold = scores[scores.length / 2]
315 if threshold == 0 then threshold = 1 end
316 mhash = Hash.new
317 phash.keys.shuffle.select do |k|
318 if phash[k] < threshold or k.description == "" then
319 false
320 else
321 u = k.users_by_role
322 mgrs = []
323 u.keys.each do |r|
324 if r.allowed_to?(:edit_project)
325 u[r].each { |m| mgrs << m }
326 end
327 end
328 novel = (mhash.keys & mgrs).empty?
329 mgrs.each { |m| mhash[m] = 1 }
330 novel and not mgrs.empty?
331 end
332 end.sample(count)
333 end
334
301 end 335 end