Sha256: 07320e29fb9381e4ebbdf76e6d1dd7ea02f1bf8597d238d4d87c3a3a05ed48b2

Contents?: true

Size: 1.3 KB

Versions: 25

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

module Decidim
  module Conferences
    module Admin
      # A class used to find the ConferenceSpeakers's by the search.
      class ConferenceSpeakers < Decidim::Query
        # Syntactic sugar to initialize the class and return the queried objects.
        #
        # conference_speakers - the initial ConferenceSpeaker relation that needs to be filtered.
        # query - query to filter user group names
        def self.for(conference_speakers, query = nil)
          new(conference_speakers, query).query
        end

        # Initializes the class.
        #
        # conference_speakers - the ConferenceSpeaker relation that need to be filtered
        # query - query to filter user group names
        def initialize(conference_speakers, query = nil)
          @conference_speakers = conference_speakers
          @query = query
        end

        # List the conference speakers by the different filters.
        def query
          @conference_speakers = filter_by_search(@conference_speakers)
          @conference_speakers
        end

        private

        def filter_by_search(conference_speakers)
          return conference_speakers if @query.blank?

          conference_speakers.where("LOWER(full_name) LIKE LOWER(?)", "%#{@query}%")
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
decidim-conferences-0.29.1 app/queries/decidim/conferences/admin/conference_speakers.rb
decidim-conferences-0.28.4 app/queries/decidim/conferences/admin/conference_speakers.rb
decidim-conferences-0.27.9 app/queries/decidim/conferences/admin/conference_speakers.rb
decidim-conferences-0.29.0 app/queries/decidim/conferences/admin/conference_speakers.rb
decidim-conferences-0.28.3 app/queries/decidim/conferences/admin/conference_speakers.rb
decidim-conferences-0.27.8 app/queries/decidim/conferences/admin/conference_speakers.rb
decidim-conferences-0.29.0.rc4 app/queries/decidim/conferences/admin/conference_speakers.rb
decidim-conferences-0.29.0.rc3 app/queries/decidim/conferences/admin/conference_speakers.rb
decidim-conferences-0.29.0.rc2 app/queries/decidim/conferences/admin/conference_speakers.rb
decidim-conferences-0.29.0.rc1 app/queries/decidim/conferences/admin/conference_speakers.rb
decidim-conferences-0.28.2 app/queries/decidim/conferences/admin/conference_speakers.rb
decidim-conferences-0.27.7 app/queries/decidim/conferences/admin/conference_speakers.rb
decidim-conferences-0.28.1 app/queries/decidim/conferences/admin/conference_speakers.rb
decidim-conferences-0.27.6 app/queries/decidim/conferences/admin/conference_speakers.rb
decidim-conferences-0.28.0 app/queries/decidim/conferences/admin/conference_speakers.rb
decidim-conferences-0.27.5 app/queries/decidim/conferences/admin/conference_speakers.rb
decidim-conferences-0.28.0.rc5 app/queries/decidim/conferences/admin/conference_speakers.rb
decidim-conferences-0.28.0.rc4 app/queries/decidim/conferences/admin/conference_speakers.rb
decidim-conferences-0.27.4 app/queries/decidim/conferences/admin/conference_speakers.rb
decidim-conferences-0.27.3 app/queries/decidim/conferences/admin/conference_speakers.rb