From f8c97b9bb9c26b9f837d48926371d6db7dbb6a4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sun, 17 Mar 2024 22:40:11 +0100 Subject: [PATCH] Remove monkey-patch of the Numeric class This monkey-patch doesn't seem to be working with Zeitwerk, and we were only using it in one place, so the easiest way to solve the problem is to remove it. Note that, in the process, we're changing the operation so `* 100` appears before the division, so it's consistent with other places where we do similar things (like the `supports_percentage` method in the proposals helper). --- app/helpers/votes_helper.rb | 2 +- app/models/debate.rb | 2 -- lib/numeric.rb | 5 ----- 3 files changed, 1 insertion(+), 8 deletions(-) delete mode 100644 lib/numeric.rb diff --git a/app/helpers/votes_helper.rb b/app/helpers/votes_helper.rb index 8292717e4..9772a8f04 100644 --- a/app/helpers/votes_helper.rb +++ b/app/helpers/votes_helper.rb @@ -1,6 +1,6 @@ module VotesHelper def debate_percentage_of_likes(debate) - debate.likes.percent_of(debate.total_votes) + (debate.likes.to_f * 100 / debate.total_votes).to_i end def votes_percentage(vote, debate) diff --git a/app/models/debate.rb b/app/models/debate.rb index 4316b4777..c4ca74af0 100644 --- a/app/models/debate.rb +++ b/app/models/debate.rb @@ -1,5 +1,3 @@ -require "numeric" - class Debate < ApplicationRecord include Flaggable include Taggable diff --git a/lib/numeric.rb b/lib/numeric.rb deleted file mode 100644 index ab9b212b9..000000000 --- a/lib/numeric.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Numeric - def percent_of(n) - (to_f / n * 100).to_i - end -end