Class: Decidim::Core::MetricResolver
- Inherits:
-
Object
- Object
- Decidim::Core::MetricResolver
- Defined in:
- app/resolvers/decidim/core/metric_resolver.rb
Overview
A GraphQL resolver to handle ‘count` and `metric` queries
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #count ⇒ Object
- #history ⇒ Object
-
#initialize(name, organization, filters = {}) ⇒ MetricResolver
constructor
-
name: name identifier of metric - organization: Decidim::Organization scoping - filters: hash of attr - value to filter results.
-
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 '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
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'app/resolvers/decidim/core/metric_resolver.rb', line 7 def name @name end |
Instance Method Details
#count ⇒ Object
22 23 24 |
# File 'app/resolvers/decidim/core/metric_resolver.rb', line 22 def count resolve.max.try(:last) || 0 end |
#history ⇒ Object
26 27 28 |
# File 'app/resolvers/decidim/core/metric_resolver.rb', line 26 def history resolve end |