Class: Specwrk::Web::Endpoints::Seed
- Defined in:
- lib/specwrk/web/endpoints/seed.rb
Constant Summary
Constants inherited from Base
Base::InvalidGzipError, Base::MUTEX, Base::UnsupportedContentEncodingError
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Specwrk::Web::Endpoints::Base
Instance Method Details
#examples_with_run_times ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/specwrk/web/endpoints/seed.rb', line 33 def examples_with_run_times @examples_with_run_times ||= begin unsorted_examples_with_run_times = [] all_ids = payload[:examples].map { |example| example[:id] } all_run_times = run_times.multi_read(*all_ids) payload[:examples].each do |example| run_time = all_run_times[example[:id]] unsorted_examples_with_run_times << [example[:id], example.merge(expected_run_time: run_time)] end sorted_examples_with_run_times = if sort_by == :timings unsorted_examples_with_run_times.sort_by do |entry| -(entry.last[:expected_run_time] || Float::INFINITY) end else unsorted_examples_with_run_times.sort_by do |entry| entry.last[:file_path] end end @seeds_run_time_bucket_maximum = run_time_bucket_maximum(all_run_times.values.compact) @examples_with_run_times = sorted_examples_with_run_times.to_h end end |
#with_response ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/specwrk/web/endpoints/seed.rb', line 9 def with_response Hooks.run(:before_server_seed) examples_with_run_times pending.clear processing.clear failure_counts.clear completed.clear pending.max_retries = payload.fetch(:max_retries, "0").to_i pending.update_run_time_bucket_maximum( @seeds_run_time_bucket_maximum, target_bucket_timing_duration: payload.fetch(:target_bucket_timing_duration, 0) ) with_lock do pending.merge!(examples_with_run_times) end Hooks.run(:after_server_seed, payload[:examples]) ok end |