add reputation view and improve queries

This commit is contained in:
2021-05-02 00:55:20 +02:00
parent d227cdc87c
commit 1533f539da
9 changed files with 39 additions and 5 deletions

View 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