Class: Decidim::Votings::Admin::PollingOfficersJoinUser

Inherits:
Rectify::Query
  • Object
show all
Defined in:
decidim-elections/app/queries/decidim/votings/admin/polling_officers_join_user.rb

Overview

A class join the polling officers with their respective decidim user.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(polling_officers) ⇒ PollingOfficersJoinUser

Initializes the class.

polling_officers - the collection of polling officers


18
19
20
# File 'decidim-elections/app/queries/decidim/votings/admin/polling_officers_join_user.rb', line 18

def initialize(polling_officers)
  @polling_officers = polling_officers
end

Class Method Details

.for(polling_officers) ⇒ Object

Syntactic sugar to initialize the class and return the queried objects.

polling_officers - the collection of polling officers


11
12
13
# File 'decidim-elections/app/queries/decidim/votings/admin/polling_officers_join_user.rb', line 11

def self.for(polling_officers)
  new(polling_officers).query
end

Instance Method Details

#queryObject

Joins the polling officers with their associated decidim user.

Returns an ActiveRecord::Relation.


25
26
27
28
# File 'decidim-elections/app/queries/decidim/votings/admin/polling_officers_join_user.rb', line 25

def query
  @polling_officers
    .joins("LEFT JOIN decidim_users ON decidim_users.id = decidim_votings_polling_officers.decidim_user_id")
end