Sha256: 24d5f3a13454203bb76ec322fd446d3203631d948fba040965b49467daae5886

Contents?: true

Size: 1.01 KB

Versions: 33

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module Decidim
  module Debates
    # This class handles search and filtering of debates. Needs a
    # `current_component` param with a `Decidim::Component` in order to
    # find the debates.
    class DebateSearch < ResourceSearch
      text_search_fields :title, :description

      # Public: Initializes the service.
      # component     - A Decidim::Component to get the debates from.
      # page        - The page number to paginate the results.
      # per_page    - The number of debates to return per page.
      def initialize(options = {})
        super(Debate.not_hidden, options)
      end

      # Handle the activity filter
      def search_activity
        case activity
        when "commented"
          query.commented_by(user)
        when "my_debates"
          query.authored_by(user)
        else # Assume 'all'
          query
        end
      end

      # Handle the state filter
      def search_state
        apply_scopes(%w(open closed), state)
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
decidim-debates-0.26.10 app/services/decidim/debates/debate_search.rb
decidim-debates-0.26.9 app/services/decidim/debates/debate_search.rb
decidim-debates-0.26.8 app/services/decidim/debates/debate_search.rb
decidim-debates-0.26.7 app/services/decidim/debates/debate_search.rb
decidim-debates-0.26.5 app/services/decidim/debates/debate_search.rb
decidim-debates-0.26.4 app/services/decidim/debates/debate_search.rb
decidim-debates-0.26.3 app/services/decidim/debates/debate_search.rb
decidim-debates-0.26.2 app/services/decidim/debates/debate_search.rb
decidim-debates-0.26.1 app/services/decidim/debates/debate_search.rb
decidim-debates-0.26.0 app/services/decidim/debates/debate_search.rb
decidim-debates-0.26.0.rc2 app/services/decidim/debates/debate_search.rb
decidim-debates-0.26.0.rc1 app/services/decidim/debates/debate_search.rb
decidim-debates-0.25.2 app/services/decidim/debates/debate_search.rb
decidim-debates-0.25.1 app/services/decidim/debates/debate_search.rb
decidim-debates-0.25.0 app/services/decidim/debates/debate_search.rb
decidim-debates-0.25.0.rc4 app/services/decidim/debates/debate_search.rb
decidim-debates-0.25.0.rc3 app/services/decidim/debates/debate_search.rb
decidim-debates-0.25.0.rc2 app/services/decidim/debates/debate_search.rb
decidim-debates-0.25.0.rc1 app/services/decidim/debates/debate_search.rb
decidim-debates-0.24.3 app/services/decidim/debates/debate_search.rb