Class: Decidim::ParticipatoryProcesses::StatsParticipantsCount

Inherits:
Rectify::Query
  • Object
show all
Defined in:
decidim-participatory_processes/app/queries/decidim/participatory_processes/stats_participants_count.rb

Overview

This class counts unique Participants on a participatory process or participatory processes belonging to a participatory process group

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(participatory_space) ⇒ StatsParticipantsCount

Returns a new instance of StatsParticipantsCount.


15
16
17
# File 'decidim-participatory_processes/app/queries/decidim/participatory_processes/stats_participants_count.rb', line 15

def initialize(participatory_space)
  @participatory_space = participatory_space
end

Class Method Details

.for(participatory_space) ⇒ Object


8
9
10
11
12
13
# File 'decidim-participatory_processes/app/queries/decidim/participatory_processes/stats_participants_count.rb', line 8

def self.for(participatory_space)
  return 0 unless participatory_space.is_a?(Decidim::ParticipatoryProcess) ||
                  participatory_space.is_a?(Decidim::ParticipatoryProcessGroup) && participatory_space.participatory_processes.exists?

  new(participatory_space).query
end

Instance Method Details

#queryObject


19
20
21
22
23
24
25
26
27
28
29
# File 'decidim-participatory_processes/app/queries/decidim/participatory_processes/stats_participants_count.rb', line 19

def query
  [
    comments_query,
    debates_query,
    endorsements_query,
    project_supports_query,
    proposals_query,
    proposal_supports_query,
    survey_answer_query
  ].flatten.uniq.count
end