lib/eco/api/session/batch/job.rb in eco-helpers-3.0.20 vs lib/eco/api/session/batch/job.rb in eco-helpers-3.0.21
- old
+ new
@@ -144,10 +144,20 @@
# @return [Boolean] has been this `batch job` launched?
def pending?
@pending
end
+ # @note some times we need a summary of what actually
+ # is going to be run without invoking `launch`
+ # (i.e. when there's a uncompliance with the batch policy)
+ def ensure_requests!
+ return if instance_variable_defined?(:@requests)
+
+ pqueue = processed_queue
+ @requests = as_update(pqueue)
+ end
+
# @note it requires launch to be firstly invoked
# @raise [Exception] if 'launch' has not firstly invoked
# @return [Enumbrable<Hash>] the last requests that the queue will generate
def requests
msg = "Method missuse. Firstly 'launch' should be invoked"
@@ -248,9 +258,10 @@
# @note if `launch` was not invoked, it specifies so
# @return [String] the summary
def summary
[].tap do |msg|
msg << "PENDING Job -------->\n" if pending?
+ ensure_requests!
msg << feedback.generate(requests, only_stats: true)
if batch_policy && !batch_policy.compliant?(request_stats)
msg << 'Batch Policy Uncompliance:'
msg << batch_policy.uncompliance(request_stats)