add reputation view and improve queries
This commit is contained in:
15
app/helpers/wow_standings_helper.rb
Normal file
15
app/helpers/wow_standings_helper.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module WowStandingsHelper
|
||||
def reput_pourcentage(standing, tier)
|
||||
max = tier.max_value
|
||||
min = tier.min_value
|
||||
value = standing.value
|
||||
|
||||
return 100 if max == min
|
||||
return value * 100 / (max - min) if max.positive? && (min.positive? || min.zero?)
|
||||
return value * -100 / (min - max) if min.negative? && (max.negative? || max.zero?)
|
||||
|
||||
0
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user