Sha256: 6b849053629441e5a6636cbe99cefc5a81b917141f2702ff45489a1eea15a9c1

Contents?: true

Size: 1.21 KB

Versions: 25

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

module Decidim
  module Votings
    module Admin
      # A class join the polling officers with their respective polling stations.
      class PollingOfficersJoinPollingStations < Rectify::Query
        # Syntactic sugar to initialize the class and return the queried objects.
        #
        # polling_officers - the collection of polling officers
        def self.for(polling_officers)
          new(polling_officers).query
        end

        # Initializes the class.
        #
        # polling_officers - the collection of polling officers
        def initialize(polling_officers)
          @polling_officers = polling_officers
        end

        # Finds joins the polling officers with their associated polling stations.
        #
        # Returns an ActiveRecord::Relation.
        def query
          @polling_officers
            .joins("LEFT JOIN decidim_votings_polling_stations presided_station ON decidim_votings_polling_officers.presided_polling_station_id = presided_station.id
                    LEFT JOIN decidim_votings_polling_stations managed_station ON decidim_votings_polling_officers.managed_polling_station_id = managed_station.id")
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
decidim-elections-0.26.10 app/queries/decidim/votings/admin/polling_officers_join_polling_stations.rb
decidim-elections-0.26.9 app/queries/decidim/votings/admin/polling_officers_join_polling_stations.rb
decidim-elections-0.26.8 app/queries/decidim/votings/admin/polling_officers_join_polling_stations.rb
decidim-elections-0.26.7 app/queries/decidim/votings/admin/polling_officers_join_polling_stations.rb
decidim-elections-0.26.5 app/queries/decidim/votings/admin/polling_officers_join_polling_stations.rb
decidim-elections-0.26.4 app/queries/decidim/votings/admin/polling_officers_join_polling_stations.rb
decidim-elections-0.26.3 app/queries/decidim/votings/admin/polling_officers_join_polling_stations.rb
decidim-elections-0.26.2 app/queries/decidim/votings/admin/polling_officers_join_polling_stations.rb
decidim-elections-0.26.1 app/queries/decidim/votings/admin/polling_officers_join_polling_stations.rb
decidim-elections-0.26.0 app/queries/decidim/votings/admin/polling_officers_join_polling_stations.rb
decidim-elections-0.26.0.rc2 app/queries/decidim/votings/admin/polling_officers_join_polling_stations.rb
decidim-elections-0.26.0.rc1 app/queries/decidim/votings/admin/polling_officers_join_polling_stations.rb
decidim-elections-0.25.2 app/queries/decidim/votings/admin/polling_officers_join_polling_stations.rb
decidim-elections-0.25.1 app/queries/decidim/votings/admin/polling_officers_join_polling_stations.rb
decidim-elections-0.25.0 app/queries/decidim/votings/admin/polling_officers_join_polling_stations.rb
decidim-elections-0.25.0.rc4 app/queries/decidim/votings/admin/polling_officers_join_polling_stations.rb
decidim-elections-0.25.0.rc3 app/queries/decidim/votings/admin/polling_officers_join_polling_stations.rb
decidim-elections-0.25.0.rc2 app/queries/decidim/votings/admin/polling_officers_join_polling_stations.rb
decidim-elections-0.25.0.rc1 app/queries/decidim/votings/admin/polling_officers_join_polling_stations.rb
decidim-elections-0.24.3 app/queries/decidim/votings/admin/polling_officers_join_polling_stations.rb