Class: Perchfall::Rails::SyntheticRun::Persist

Inherits:
Object
  • Object
show all
Defined in:
app/services/perchfall/rails/synthetic_run/persist.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(report, url:, scenario_name:) ⇒ Persist

Returns a new instance of Persist.



11
12
13
14
15
# File 'app/services/perchfall/rails/synthetic_run/persist.rb', line 11

def initialize(report, url:, scenario_name:)
  @report        = report
  @url           = url
  @scenario_name = scenario_name
end

Class Method Details

.call(report, url:, scenario_name: nil) ⇒ Object



7
8
9
# File 'app/services/perchfall/rails/synthetic_run/persist.rb', line 7

def self.call(report, url:, scenario_name: nil)
  new(report, url: url, scenario_name: scenario_name).call
end

Instance Method Details

#callObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/services/perchfall/rails/synthetic_run/persist.rb', line 17

def call
  SyntheticRun.create!(
    url: @url,
    scenario_name: @scenario_name,
    status: map_status,
    http_status: @report.http_status,
    duration_ms: @report.duration_ms,
    network_error_count: @report.network_errors.size,
    console_error_count: @report.console_errors.size,
    raw_report: @report.to_h
  )
end