lib/attractor/suggester.rb in attractor-0.3.4 vs lib/attractor/suggester.rb in attractor-0.4.0

- old
+ new

@@ -5,14 +5,15 @@ class Suggester def initialize(values) @values = values end - def suggest + def suggest(threshold = 95) products = @values.map { |val| val.churn * val.complexity } products.extend(DescriptiveStatistics) - top_95_quantile = products.percentile(95) + quantile = products.percentile(threshold.to_i) - @values.select { |val| val.churn * val.complexity > top_95_quantile } + @values.select { |val| val.churn * val.complexity > quantile } + .sort_by { |val| val.churn * val.complexity }.reverse end end end