Class: Decidim::Core::MetricResolver

Inherits:
Object
  • Object
show all
Defined in:
decidim-core/app/resolvers/decidim/core/metric_resolver.rb

Overview

A GraphQL resolver to handle `count` and `metric` queries

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, organization, filters = {}) ⇒ MetricResolver

  • name: name identifier of metric

  • organization: Decidim::Organization scoping

  • filters: hash of attr - value to filter results


14
15
16
17
18
19
20
# File 'decidim-core/app/resolvers/decidim/core/metric_resolver.rb', line 14

def initialize(name, organization, filters = {})
  @name = name
  @organization = organization
  @filters = filters
  @group_by = :day
  @counter_field = :cumulative
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name


7
8
9
# File 'decidim-core/app/resolvers/decidim/core/metric_resolver.rb', line 7

def name
  @name
end

Instance Method Details

#countObject


22
23
24
# File 'decidim-core/app/resolvers/decidim/core/metric_resolver.rb', line 22

def count
  resolve.max.try(:last) || 0
end

#historyObject


26
27
28
# File 'decidim-core/app/resolvers/decidim/core/metric_resolver.rb', line 26

def history
  resolve
end