Class: Eco::API::UseCases::GraphQL::Helpers::Location::Command::Results
- Inherits:
-
Object
- Object
- Eco::API::UseCases::GraphQL::Helpers::Location::Command::Results
- Defined in:
- lib/eco/api/usecases/graphql/helpers/location/command/results.rb
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #applied ⇒ Object
- #applied? ⇒ Boolean
- #count ⇒ Object
-
#error ⇒ Object
Overal errors (i.e. ID clashes between different structures).
- #error? ⇒ Boolean
- #errored ⇒ Object
- #errored? ⇒ Boolean
- #first_errored ⇒ Object
- #first_errored_idx ⇒ Object
-
#force? ⇒ Boolean
Was this configured to force-continue on command error?.
- #idx(result) ⇒ Object
-
#initialize(input, response) ⇒ Results
constructor
A new instance of Results.
- #input_idx(input) ⇒ Object
- #input_result(input) ⇒ Object
- #last_applied ⇒ Object
- #last_applied_idx ⇒ Object
- #pending ⇒ Object
- #results ⇒ Object
- #some_applied? ⇒ Boolean
- #some_pending? ⇒ Boolean
- #stats ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(input, response) ⇒ Results
Returns a new instance of Results.
5 6 7 8 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 5 def initialize(input, response) @input = input @response = response end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
3 4 5 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 3 def input @input end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
3 4 5 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 3 def response @response end |
Instance Method Details
#applied ⇒ Object
82 83 84 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 82 def applied @applied ||= results.select {|r| r.applied?} end |
#applied? ⇒ Boolean
86 87 88 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 86 def applied? results.all? {|r| r.applied?} end |
#count ⇒ Object
50 51 52 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 50 def count results.count end |
#error ⇒ Object
Overal errors (i.e. ID clashes between different structures)
32 33 34 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 32 def error response&.error end |
#error? ⇒ Boolean
36 37 38 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 36 def error? !!error end |
#errored ⇒ Object
66 67 68 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 66 def errored @errored ||= results.select {|r| r.error?} end |
#errored? ⇒ Boolean
70 71 72 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 70 def errored? !errored.empty? end |
#first_errored ⇒ Object
74 75 76 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 74 def first_errored errored.first end |
#first_errored_idx ⇒ Object
78 79 80 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 78 def first_errored_idx idx(first_errored) end |
#force? ⇒ Boolean
Was this configured to force-continue on command error?
21 22 23 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 21 def force? input[:force] end |
#idx(result) ⇒ Object
62 63 64 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 62 def idx(result) results.index(result) end |
#input_idx(input) ⇒ Object
58 59 60 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 58 def input_idx(input) results.index(input_result(input)) end |
#input_result(input) ⇒ Object
54 55 56 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 54 def input_result(input) results_by_input[input] end |
#last_applied ⇒ Object
94 95 96 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 94 def last_applied applied.last end |
#last_applied_idx ⇒ Object
98 99 100 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 98 def last_applied_idx idx(last_applied) end |
#pending ⇒ Object
102 103 104 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 102 def pending @pending ||= results.select {|r| r.pending?} end |
#results ⇒ Object
44 45 46 47 48 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 44 def results @results ||= input_commands.zip(response_results).each_with_object([]) do |(i, r), results| results << Result.new(i, r) end end |
#some_applied? ⇒ Boolean
90 91 92 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 90 def some_applied? applied.count > 0 end |
#some_pending? ⇒ Boolean
106 107 108 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 106 def some_pending? !pending.empty? end |
#stats ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 10 def stats msg = '' first_err = force? ? '' : "(stopped on node: '#{first_errored&.node_id}' - idx: #{first_errored_idx})" msg << " • Errored: #{errored.count} #{first_err}\n" if errored? last_okay = force? ? '' : "(last node done: '#{last_applied&.node_id}' - idx: #{last_applied_idx})" msg << " • Applied: #{errored.count} #{last_okay}\n" if some_applied? msg << " • Pending: #{pending.count}\n" if some_pending? msg end |
#success? ⇒ Boolean
40 41 42 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/results.rb', line 40 def success? !error? && results.all? {|r| r.success?} end |