Sha256: 5eae87638a7b83166348a222abf991585819849086ed4098a50f0f81d103af6d

Contents?: true

Size: 673 Bytes

Versions: 13

Compression:

Stored size: 673 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 < Decidim::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:).published.open
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-initiatives-0.29.1 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb
decidim-initiatives-0.28.4 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb
decidim-initiatives-0.29.0 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb
decidim-initiatives-0.28.3 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb
decidim-initiatives-0.29.0.rc4 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb
decidim-initiatives-0.29.0.rc3 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb
decidim-initiatives-0.29.0.rc2 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb
decidim-initiatives-0.29.0.rc1 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb
decidim-initiatives-0.28.2 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb
decidim-initiatives-0.28.1 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb
decidim-initiatives-0.28.0 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb
decidim-initiatives-0.28.0.rc5 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb
decidim-initiatives-0.28.0.rc4 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb