Skip to content
Snippets Groups Projects
Commit b11fdd54 authored by Mateus Rambo Strey's avatar Mateus Rambo Strey
Browse files

small fixes

parent de2a68a9
No related branches found
No related tags found
No related merge requests found
......@@ -3,4 +3,5 @@ class TopicRelationship < ActiveRecord::Base
belongs_to :child, class_name: 'Topic'
validates_presence_of :parent, :child
validates_uniqueness_of :child, scope: :parent
end
......@@ -17,7 +17,9 @@ class ScoreCalculatorService
sum = 0
Score.all.find_each do |score|
sum += (values[score.code.to_sym].to_f / score.max_value.to_f) * score.weight.to_f unless score.max_value.to_f == 0
next if score.max_value.to_f == 0
sum += (values[score.code.to_sym].to_f / score.max_value.to_f) * score.weight.to_f
end
sum.to_f / sum_weights.to_f
......@@ -41,7 +43,7 @@ class ScoreCalculatorService
end
def sum_weights
Score.pluck(:weight).inject(0){|sum,r| sum + r }.to_f
Score.pluck(:weight).inject(0.0) { |a, e| a + e }
end
end
......@@ -24,7 +24,7 @@ reputations = [
]
values = [
[0,0,0,0,0,0,0,0,0], # Iniciante
[ 0, 0, 0, 0, 0, 0, 0, 0, 0], # Iniciante
[ 25, 3.0, 10, 500, 250, 70, 50, 5, 400], # Novato
[ 50, 3.8, 20, 550, 350, 85, 250, 15, 600], # Amador
[ 100, 4.2, 40, 600, 450, 90, 1000, 25, 750], # Profissional
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment