Class: Decidim::Accountability::ResultsCalculator

Inherits:
Object
  • Object
show all
Defined in:
app/services/decidim/accountability/results_calculator.rb

Overview

This class handles the calculation of progress for a set of results

Instance Method Summary collapse

Constructor Details

#initialize(component, scope_id, category_id) ⇒ ResultsCalculator

Public: Initializes the service.



8
9
10
11
12
# File 'app/services/decidim/accountability/results_calculator.rb', line 8

def initialize(component, scope_id, category_id)
  @component = component
  @scope_id = scope_id
  @category_id = category_id
end

Instance Method Details

#progressObject



16
17
18
# File 'app/services/decidim/accountability/results_calculator.rb', line 16

def progress
  results.average("COALESCE(progress, 0)")
end