Class: Decidim::ActionDelegator::Scrutiny

Inherits:
Object
  • Object
show all
Defined in:
app/queries/decidim/action_delegator/scrutiny.rb

Instance Method Summary collapse

Constructor Details

#initialize(consultation) ⇒ Scrutiny

Returns a new instance of Scrutiny.



15
16
17
18
# File 'app/queries/decidim/action_delegator/scrutiny.rb', line 15

def initialize(consultation)
  @consultation = consultation
  @question_votes_by_id = questions_query.group_by(&:id)
end

Instance Method Details

#questionsObject



20
21
22
23
24
25
26
27
28
# File 'app/queries/decidim/action_delegator/scrutiny.rb', line 20

def questions
  questions_cache = build_questions_cache

  question_votes_by_id.map do |_id, question_votes|
    # They are all the same question so we can pick any
    question = question_votes.first
    QuestionWithTotals.new(question, questions_cache)
  end
end