From fb2c92228ab5bc2309dfb462bd6f2ed33e57c31d Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 21 Feb 2018 01:07:25 +0100 Subject: [PATCH] Refactor UserSegment class Simple refactor to avoid creating unnecessary variables and make it easier to read. --- lib/user_segments.rb | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/lib/user_segments.rb b/lib/user_segments.rb index 8a50f6d31..dd26132d0 100644 --- a/lib/user_segments.rb +++ b/lib/user_segments.rb @@ -11,30 +11,24 @@ class UserSegments end def self.proposal_authors - author_ids = Proposal.not_archived.not_retired.pluck(:author_id).uniq - author_ids(author_ids) + author_ids(Proposal.not_archived.not_retired.pluck(:author_id).uniq) end def self.investment_authors - author_ids = current_budget_investments.pluck(:author_id).uniq - author_ids(author_ids) + author_ids(current_budget_investments.pluck(:author_id).uniq) end def self.feasible_and_undecided_investment_authors - author_ids = current_budget_investments.where(feasibility: %w(feasible undecided)) - .pluck(:author_id).uniq - - author_ids(author_ids) + feasibility = %w(feasible undecided) + author_ids(current_budget_investments.where(feasibility: feasibility).pluck(:author_id).uniq) end def self.selected_investment_authors - author_ids = current_budget_investments.selected.pluck(:author_id).uniq - author_ids(author_ids) + author_ids(current_budget_investments.selected.pluck(:author_id).uniq) end def self.winner_investment_authors - author_ids = current_budget_investments.winners.pluck(:author_id).uniq - author_ids(author_ids) + author_ids(current_budget_investments.winners.pluck(:author_id).uniq) end private