Sha256: a6d25c8400131decd1b7c2d0d5d40e88ed101527402fdb20f60280597b64e730

Contents?: true

Size: 1.49 KB

Versions: 10

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true
# Maintain a cache of summary test data for scenario runs
module QaServer
  class ScenarioRunSummaryCache
    class_attribute :scenario_history_class
    self.scenario_history_class = QaServer::ScenarioRunHistory

    class << self
      include QaServer::CacheKeys

      # Summary for a run
      # @param run [QaServer::ScenarioRunRegistry]
      # @returns [QaServer::ScenarioRunSummary] statistics on the requested run
      # @example ScenarioRunSummary includes methods for accessing
      #   * run_id           [Integer] e.g. 14
      #   * run_dt_stamp     [ActiveSupport::TimeWithZone] e.g. Wed, 19 Feb 2020 16:01:07 UTC +00:00
      #   * authority_count  [Integer] e.g. 22
      #   * failing_authority_count [Integer] e.g. 1
      #   * passing_scenario_count  [Integer] e.g. 156
      #   * failing_scenario_count  [Integer] e.g. 3
      #   * total_scenario_count    [Integer] e.g. 159
      def summary_for_run(run:)
        Rails.cache.fetch(cache_key_for_run_summary(run.id), expires_in: next_expiry, race_condition_ttl: 30.seconds) do
          QaServer.config.monitor_logger.debug("(QaServer::ScenarioRunSummaryCache) - CALCULATING SUMMARY for scenario run #{run.id}")
          scenario_history_class.run_summary(scenario_run: run)
        end
      end

    private

      def cache_key_for_run_summary(id)
        "#{SCENARIO_RUN_SUMMARY_DATA_CACHE_KEY}--#{id}"
      end

      def next_expiry
        QaServer::CacheExpiryService.cache_expiry
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
qa_server-8.0.1 app/cache_processors/qa_server/scenario_run_summary_cache.rb
qa_server-7.9.2 app/cache_processors/qa_server/scenario_run_summary_cache.rb
qa_server-7.9.1 app/cache_processors/qa_server/scenario_run_summary_cache.rb
qa_server-7.9.0 app/cache_processors/qa_server/scenario_run_summary_cache.rb
qa_server-7.8.0 app/cache_processors/qa_server/scenario_run_summary_cache.rb
qa_server-7.7.1 app/cache_processors/qa_server/scenario_run_summary_cache.rb
qa_server-7.7.0 app/cache_processors/qa_server/scenario_run_summary_cache.rb
qa_server-7.6.0 app/cache_processors/qa_server/scenario_run_summary_cache.rb
qa_server-7.5.1 app/cache_processors/qa_server/scenario_run_summary_cache.rb
qa_server-7.5.0 app/cache_processors/qa_server/scenario_run_summary_cache.rb