Class: Specwrk::Web::Endpoints::Seed
- Inherits:
-
Base
- Object
- Base
- Specwrk::Web::Endpoints::Seed
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
Instance Method Details
#before_lock ⇒ Object
9
10
11
|
# File 'lib/specwrk/web/endpoints/seed.rb', line 9
def before_lock
examples_with_run_times
end
|
#examples_with_run_times ⇒ Object
30
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
|
# File 'lib/specwrk/web/endpoints/seed.rb', line 30
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
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/specwrk/web/endpoints/seed.rb', line 13
def with_response
pending.clear
processing.clear
failure_counts.clear
pending.max_retries = payload.fetch(:max_retries, "0").to_i
new_run_time_bucket_maximums = [pending.run_time_bucket_maximum, @seeds_run_time_bucket_maximum.to_f].compact
pending.run_time_bucket_maximum = new_run_time_bucket_maximums.sum.to_f / new_run_time_bucket_maximums.length.to_f
pending.merge!(examples_with_run_times)
processing.clear
completed.clear
ok
end
|