Sha256: 0ed044e007bf95ada513af63af58163182ffaf63217ae0c996386a07a67b9f80

Contents?: true

Size: 790 Bytes

Versions: 63

Compression:

Stored size: 790 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Accountability
    # This class handles the calculation of progress for a set of results
    class ResultsCalculator
      # Public: Initializes the service.
      def initialize(component, scope_id, category_id)
        @component = component
        @scope_id = scope_id
        @category_id = category_id
      end

      delegate :count, to: :results

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

      private

      attr_reader :component, :scope_id, :category_id

      def results
        @results ||= ResultSearch.new(
          component: component,
          scope_id: scope_id,
          category_id: category_id,
          deep_search: false
        ).results
      end
    end
  end
end

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
decidim-accountability-0.26.10 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.26.9 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.26.8 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.26.7 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.26.5 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.26.4 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.26.3 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.26.2 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.26.1 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.26.0 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.26.0.rc2 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.26.0.rc1 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.25.2 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.25.1 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.25.0 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.25.0.rc4 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.25.0.rc3 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.25.0.rc2 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.25.0.rc1 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.24.3 app/services/decidim/accountability/results_calculator.rb