Class: Decidim::ActionDelegator::Responses

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

Instance Method Summary collapse

Constructor Details

#initialize(consultation) ⇒ Responses

Returns a new instance of Responses.



6
7
8
# File 'app/queries/decidim/action_delegator/responses.rb', line 6

def initialize(consultation)
  @consultation = consultation
end

Instance Method Details

#queryObject

The Question’s default_scope, ‘order(order: :asc)`, messes up the ordering in our queries so we have to explicitly remove the ORDER BY close using `#reorder`.



12
13
14
15
16
17
# File 'app/queries/decidim/action_delegator/responses.rb', line 12

def query
  Decidim::Consultations::Response
    .joins(question: :consultation)
    .where(decidim_consultations_questions: { decidim_consultation_id: consultation.id })
    .where.not(decidim_consultations_questions: { published_at: nil })
end