Class: Decidim::ActionDelegator::VotesCountAggregation
- Inherits:
-
Object
- Object
- Decidim::ActionDelegator::VotesCountAggregation
- Defined in:
- app/queries/decidim/action_delegator/votes_count_aggregation.rb
Instance Method Summary collapse
-
#initialize(field, aliaz) ⇒ VotesCountAggregation
constructor
A new instance of VotesCountAggregation.
- #to_sql ⇒ Object
Constructor Details
#initialize(field, aliaz) ⇒ VotesCountAggregation
Returns a new instance of VotesCountAggregation.
6 7 8 9 |
# File 'app/queries/decidim/action_delegator/votes_count_aggregation.rb', line 6 def initialize(field, aliaz) @field = field @aliaz = aliaz end |
Instance Method Details
#to_sql ⇒ Object
11 12 13 14 15 |
# File 'app/queries/decidim/action_delegator/votes_count_aggregation.rb', line 11 def to_sql int_field = cast(field, :integer) int_field = coalesce(int_field, 1) Arel::Nodes::Sum.new([int_field], aliaz).to_sql end |