From 3dcd7b444ae94f10de5903b1be98378c6991eaa5 Mon Sep 17 00:00:00 2001 From: kikito Date: Wed, 28 Dec 2016 17:29:49 +0100 Subject: [PATCH] adds valuation_finished_feasible scope --- app/models/budget/investment.rb | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index 14109ba93..3487e8a66 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -34,17 +34,18 @@ class Budget scope :sort_by_price, -> { reorder(price: :desc, confidence_score: :desc, id: :desc) } scope :sort_by_random, -> { reorder("RANDOM()") } - scope :valuation_open, -> { where(valuation_finished: false) } - scope :without_admin, -> { valuation_open.where(administrator_id: nil) } - scope :managed, -> { valuation_open.where(valuator_assignments_count: 0).where("administrator_id IS NOT ?", nil) } - scope :valuating, -> { valuation_open.where("valuator_assignments_count > 0 AND valuation_finished = ?", false) } - scope :valuation_finished, -> { where(valuation_finished: true) } - scope :feasible, -> { where(feasibility: "feasible") } - scope :unfeasible, -> { where(feasibility: "unfeasible") } - scope :not_unfeasible, -> { where.not(feasibility: "unfeasible") } - scope :undecided, -> { where(feasibility: "undecided") } - scope :with_supports, -> { where('cached_votes_up > 0') } - scope :selected, -> { where(selected: true) } + scope :valuation_open, -> { where(valuation_finished: false) } + scope :without_admin, -> { valuation_open.where(administrator_id: nil) } + scope :managed, -> { valuation_open.where(valuator_assignments_count: 0).where("administrator_id IS NOT ?", nil) } + scope :valuating, -> { valuation_open.where("valuator_assignments_count > 0 AND valuation_finished = ?", false) } + scope :valuation_finished, -> { where(valuation_finished: true) } + scope :valuation_finished_feasible, -> { where(valuation_finished: true, feasibility: "feasible") } + scope :feasible, -> { where(feasibility: "feasible") } + scope :unfeasible, -> { where(feasibility: "unfeasible") } + scope :not_unfeasible, -> { where.not(feasibility: "unfeasible") } + scope :undecided, -> { where(feasibility: "undecided") } + scope :with_supports, -> { where('cached_votes_up > 0') } + scope :selected, -> { where(selected: true) } scope :by_group, -> (group_id) { where(group_id: group_id) } scope :by_heading, -> (heading_id) { where(heading_id: heading_id) }