Class: Perchfall::Rails::SyntheticRun::Persist
- Inherits:
-
Object
- Object
- Perchfall::Rails::SyntheticRun::Persist
- Defined in:
- app/services/perchfall/rails/synthetic_run/persist.rb
Class Method Summary collapse
- .from_error(url:, raw_report:, scenario_name: nil) ⇒ Object
- .from_report(report, url:, scenario_name: nil) ⇒ Object
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(report, url:, scenario_name:) ⇒ Persist
constructor
A new instance of Persist.
Constructor Details
#initialize(report, url:, scenario_name:) ⇒ Persist
Returns a new instance of Persist.
47 48 49 50 51 |
# File 'app/services/perchfall/rails/synthetic_run/persist.rb', line 47 def initialize(report, url:, scenario_name:) @report = report @url = url @scenario_name = scenario_name end |
Class Method Details
.from_error(url:, raw_report:, scenario_name: nil) ⇒ Object
11 12 13 14 15 16 17 |
# File 'app/services/perchfall/rails/synthetic_run/persist.rb', line 11 def self.from_error(url:, raw_report:, scenario_name: nil) persisting do SyntheticRun.create!( url: url, scenario_name: scenario_name, status: "error", raw_report: raw_report ) end end |
.from_report(report, url:, scenario_name: nil) ⇒ Object
7 8 9 |
# File 'app/services/perchfall/rails/synthetic_run/persist.rb', line 7 def self.from_report(report, url:, scenario_name: nil) persisting { new(report, url: url, scenario_name: scenario_name).call } end |
Instance Method Details
#call ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/services/perchfall/rails/synthetic_run/persist.rb', line 53 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 |