Sha256: 6ef94fcca668f7da56c0a66b2b9ac39b9c380682ce9ab999f7ccb75d1c2f103e

Contents?: true

Size: 1.11 KB

Versions: 10

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true
# Generate graphs for the past 30 days using cached data.  Graphs are generated only if the cache has expired.
module QaServer
  class ScenarioHistoryGraphCache
    class << self
      # Generates graphs for the past 30 days for :search, :fetch, and :all actions for each authority.
      # @param force [Boolean] if true, run the tests even if the cache hasn't expired; otherwise, use cache if not expired
      def generate_graph(data:, force: false)
        Rails.cache.fetch(cache_key, expires_in: next_expiry, race_condition_ttl: 30.seconds, force: force) do
          QaServer.config.monitor_logger.debug("(QaServer::ScenarioHistoryGraphCache) - KICKING OFF HISTORY GRAPH GENERATION (force: #{force})")
          QaServer::HistoryGraphJob.perform_later(data: data)
          "Graph generation initiated at #{QaServer::TimeService.current_time}"
        end
      end

    private

      def cache_key
        "QaServer::ScenarioHistoryGraphCache.generate_graph--latest_generation_initiated"
      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_history_graph_cache.rb
qa_server-7.9.2 app/cache_processors/qa_server/scenario_history_graph_cache.rb
qa_server-7.9.1 app/cache_processors/qa_server/scenario_history_graph_cache.rb
qa_server-7.9.0 app/cache_processors/qa_server/scenario_history_graph_cache.rb
qa_server-7.8.0 app/cache_processors/qa_server/scenario_history_graph_cache.rb
qa_server-7.7.1 app/cache_processors/qa_server/scenario_history_graph_cache.rb
qa_server-7.7.0 app/cache_processors/qa_server/scenario_history_graph_cache.rb
qa_server-7.6.0 app/cache_processors/qa_server/scenario_history_graph_cache.rb
qa_server-7.5.1 app/cache_processors/qa_server/scenario_history_graph_cache.rb
qa_server-7.5.0 app/cache_processors/qa_server/scenario_history_graph_cache.rb