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.23.6 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.24.2 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.23.5 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.24.1 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.24.0 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.24.0.rc2 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.23.4 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.24.0.rc1 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.23.3 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.23.2 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.23.1 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.23.1.rc1 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.23.0 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.22.0 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.21.0 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.20.1 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.20.0 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.19.1 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.18.1 app/services/decidim/accountability/results_calculator.rb
decidim-accountability-0.19.0 app/services/decidim/accountability/results_calculator.rb