Class: Specwrk::Web::Endpoints::Seed

Inherits:
Base
  • Object
show all
Defined in:
lib/specwrk/web/endpoints/seed.rb

Constant Summary

Constants inherited from Base

Base::MUTEX

Instance Attribute Summary

Attributes inherited from Base

#started_at

Instance Method Summary collapse

Methods inherited from Base

#initialize, #response

Constructor Details

This class inherits a constructor from Specwrk::Web::Endpoints::Base

Instance Method Details

#examples_with_run_timesObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/specwrk/web/endpoints/seed.rb', line 31

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_responseObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/specwrk/web/endpoints/seed.rb', line 9

def with_response
  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

  ok
end