Sha256: 489c2f75648c428f3ee16b8d267bce93ddacb93c3555147f97d3018445ec2a1b

Contents?: true

Size: 686 Bytes

Versions: 25

Compression:

Stored size: 686 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Initiatives
    # This query retrieves the organization prioritized initiatives that will appear in the homepage
    class OrganizationPrioritizedInitiatives < Rectify::Query
      attr_reader :organization, :order

      def initialize(organization, order)
        @organization = organization
        @order = order
      end

      def query
        if order == "most_recent"
          base_query.order_by_most_recently_published
        else
          base_query
        end
      end

      private

      def base_query
        Decidim::Initiative.where(organization: organization).published.open
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
decidim-initiatives-0.24.2 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb
decidim-initiatives-0.24.1 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb
decidim-initiatives-0.24.0 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb
decidim-initiatives-0.24.0.rc2 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb
decidim-initiatives-0.24.0.rc1 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb