Sha256: 91458a8184e333208b43be173cc02a753abdf6b6cb620d5b5d035ca85520f2db

Contents?: true

Size: 686 Bytes

Versions: 12

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 < 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: organization).published.open
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
decidim-initiatives-0.27.9 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb
decidim-initiatives-0.27.8 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb
decidim-initiatives-0.27.7 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb
decidim-initiatives-0.27.6 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb
decidim-initiatives-0.27.5 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb
decidim-initiatives-0.27.4 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb
decidim-initiatives-0.27.3 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb
decidim-initiatives-0.27.2 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb
decidim-initiatives-0.27.1 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb
decidim-initiatives-0.27.0 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb
decidim-initiatives-0.27.0.rc2 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb
decidim-initiatives-0.27.0.rc1 app/queries/decidim/initiatives/organization_prioritized_initiatives.rb