Class: QaServer::ScenarioRunRegistry

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
app/models/qa_server/scenario_run_registry.rb

Class Method Summary collapse

Class Method Details

.first_run_dtActiveSupport::TimeWithZone

Returns datetime stamp of first registered run.

Returns:

  • (ActiveSupport::TimeWithZone)

    datetime stamp of first registered run



27
28
29
30
31
# File 'app/models/qa_server/scenario_run_registry.rb', line 27

def self.first_run_dt
  Rails.cache.fetch("#{self.class}/#{__method__}", expires_in: QaServer::CacheExpiryService.cache_expiry, race_condition_ttl: 30.seconds) do
    QaServer::ScenarioRunRegistry.first.dt_stamp
  end
end

.latest_runScenarioRunRegistry

Returns registry data for latest run (e.g. id, dt_stamp).

Returns:



9
10
11
12
13
14
15
# File 'app/models/qa_server/scenario_run_registry.rb', line 9

def self.latest_run
  return nil unless QaServer::ScenarioRunRegistry.last
  QaServer::ScenarioRunRegistry.last # Can we count on last to always be the one with the latest dt_stamp?
  # latest_run = ScenarioRunRegistry.all.sort(:dt_stamp).last
  # return nil if latest_run.blank?
  # latest_run.id
end

.latest_run_idInteger

Deprecated.

Not used anywhere. Being removed.

Returns id for latest test run.

Returns:

  • (Integer)

    id for latest test run



19
20
21
22
23
# File 'app/models/qa_server/scenario_run_registry.rb', line 19

def self.latest_run_id
  latest = latest_run
  return nil unless latest
  lastest.id
end

.save_run(scenarios_results:) ⇒ Object

Register and save latest test run results

Parameters:

  • scenarios_results (Array<Hash>)

    results of latest test run



35
36
37
38
# File 'app/models/qa_server/scenario_run_registry.rb', line 35

def self.save_run(scenarios_results:)
  run = QaServer::ScenarioRunRegistry.create(dt_stamp: QaServer::TimeService.current_time)
  scenarios_results.each { |result| QaServer::ScenarioRunHistory.save_result(run_id: run.id, scenario_result: result) }
end