Class: Decidim::Elections::Trustees::ByParticipatorySpaceTrusteeIds

Inherits:
Query
  • Object
show all
Defined in:
decidim-elections/app/queries/decidim/elections/trustees/by_participatory_space_trustee_ids.rb

Overview

A class used to find trustees by participatory space trustee ids.

Instance Method Summary collapse

Methods inherited from Query

#cached_query, #each, #eager?, #exists?, merge, #none?, #relation?, #|

Constructor Details

#initialize(trustee_ids) ⇒ ByParticipatorySpaceTrusteeIds

Initializes the class.



10
11
12
# File 'decidim-elections/app/queries/decidim/elections/trustees/by_participatory_space_trustee_ids.rb', line 10

def initialize(trustee_ids)
  @trustee_ids = trustee_ids
end

Instance Method Details

#queryObject

Gets trustees by participatory space trustee ids.



15
16
17
18
19
20
# File 'decidim-elections/app/queries/decidim/elections/trustees/by_participatory_space_trustee_ids.rb', line 15

def query
  Decidim::Elections::Trustee
    .includes([:user])
    .joins(:trustees_participatory_spaces)
    .merge(Decidim::Elections::TrusteesParticipatorySpace.where(decidim_elections_trustee_id: @trustee_ids, considered: true))
end