Class: Decidim::ActionDelegator::ResponsesByMembership
- Inherits:
-
Query
- Object
- Query
- Decidim::ActionDelegator::ResponsesByMembership
- Defined in:
- app/queries/decidim/action_delegator/responses_by_membership.rb
Overview
Returns total votes of each response by memberships’ type and weight.
Constant Summary collapse
- DEFAULT_METADATA =
I18n.t("decidim.admin.consultations.results.default_metadata")
Instance Method Summary collapse
-
#initialize(relation) ⇒ ResponsesByMembership
constructor
A new instance of ResponsesByMembership.
- #query ⇒ Object
Constructor Details
#initialize(relation) ⇒ ResponsesByMembership
Returns a new instance of ResponsesByMembership.
9 10 11 |
# File 'app/queries/decidim/action_delegator/responses_by_membership.rb', line 9 def initialize(relation) @relation = relation end |
Instance Method Details
#query ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/queries/decidim/action_delegator/responses_by_membership.rb', line 13 def query relation .select( responses[:decidim_consultations_questions_id], responses[:title], coalesce(Ponderation.arel_table[:name], ).as("membership_type"), coalesce(Ponderation.arel_table[:weight], 1).as("membership_weight"), votes_count ) .group( responses[:decidim_consultations_questions_id], responses[:title], sql(:membership_type), sql(:membership_weight) ) .order(:title, :membership_type, { membership_weight: :desc }, "votes_count DESC") end |