Module: Decidim::Core::ParticipatorySpaceInterface

Includes:
Api::Types::BaseInterface
Defined in:
decidim-core/lib/decidim/api/interfaces/participatory_space_interface.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.resolve_type(obj, _ctx) ⇒ Object



49
50
51
# File 'decidim-core/lib/decidim/api/interfaces/participatory_space_interface.rb', line 49

def self.resolve_type(obj, _ctx)
  obj.manifest.query_type.constantize
end

Instance Method Details

#components(filter: {}, order: {}) ⇒ Object



31
32
33
# File 'decidim-core/lib/decidim/api/interfaces/participatory_space_interface.rb', line 31

def components(filter: {}, order: {})
  ComponentList.new.call(object, { filter:, order: }, context)
end

#manifestObject



22
23
24
# File 'decidim-core/lib/decidim/api/interfaces/participatory_space_interface.rb', line 22

def manifest
  ParticipatorySpaceManifestPresenter.new(object.manifest, object.organization)
end

#statsObject



37
38
39
40
41
42
43
44
45
46
47
# File 'decidim-core/lib/decidim/api/interfaces/participatory_space_interface.rb', line 37

def stats
  return if object.respond_to?(:show_statistics) && !object.show_statistics

  published_components = Component.where(participatory_space: object).published

  stats = Decidim.component_manifests.map do |component_manifest|
    component_manifest.stats.with_context(published_components).map { |name, data| [name, data] }.flatten
  end

  stats.reject(&:empty?)
end

#typeObject



18
19
20
# File 'decidim-core/lib/decidim/api/interfaces/participatory_space_interface.rb', line 18

def type
  object.class.name
end