Refactor UserSegment class

Simple refactor to avoid creating unnecessary variables and make it easier
to read.
This commit is contained in:
Bertocq
2018-02-21 01:07:25 +01:00
parent 24aa157998
commit fb2c92228a

View File

@@ -11,30 +11,24 @@ class UserSegments
end end
def self.proposal_authors def self.proposal_authors
author_ids = Proposal.not_archived.not_retired.pluck(:author_id).uniq author_ids(Proposal.not_archived.not_retired.pluck(:author_id).uniq)
author_ids(author_ids)
end end
def self.investment_authors def self.investment_authors
author_ids = current_budget_investments.pluck(:author_id).uniq author_ids(current_budget_investments.pluck(:author_id).uniq)
author_ids(author_ids)
end end
def self.feasible_and_undecided_investment_authors def self.feasible_and_undecided_investment_authors
author_ids = current_budget_investments.where(feasibility: %w(feasible undecided)) feasibility = %w(feasible undecided)
.pluck(:author_id).uniq author_ids(current_budget_investments.where(feasibility: feasibility).pluck(:author_id).uniq)
author_ids(author_ids)
end end
def self.selected_investment_authors def self.selected_investment_authors
author_ids = current_budget_investments.selected.pluck(:author_id).uniq author_ids(current_budget_investments.selected.pluck(:author_id).uniq)
author_ids(author_ids)
end end
def self.winner_investment_authors def self.winner_investment_authors
author_ids = current_budget_investments.winners.pluck(:author_id).uniq author_ids(current_budget_investments.winners.pluck(:author_id).uniq)
author_ids(author_ids)
end end
private private