module Eco::API::UseCases::GraphQL::Helpers::Location::Command::Optimizations

def commands_payload_without_structure_block

Other tags:
    Note: - this servces the purpose of optimizing/speeding up the requests.
def commands_payload_without_structure_block
  proc {
    clientMutationId
    error { # rubocop:disable Style/BlockDelimiters

      message
      conflictingIds
      validationErrors { # rubocop:disable Style/BlockDelimiters

        error
        message
      }
    }
    results { # rubocop:disable Style/BlockDelimiters

      command { # rubocop:disable Style/BlockDelimiters

        id
        state
        __typename
      }
      ok
      error { # rubocop:disable Style/BlockDelimiters

        conflictingIds
        message
        validationErrors { # rubocop:disable Style/BlockDelimiters

          error
          message
        }
      }
    }
  }
end

def commands_per_page

Prevents each request from timing out
def commands_per_page
  if self.class.const_defined?(:COMMANDS_PER_PAGE)
    self.class::COMMANDS_PER_PAGE
  else
    DEFAULT_COMMANDS_PER_PAGE
  end
end

def default_tree_tracking_mode

- :once -> only when the script starts to run
- :per_batch -> at the end of each batch / stage (on last page)
- :per_request -> on each request
Available options are:
def default_tree_tracking_mode
  :per_request
end

def force_continue?

Whether to stop or continue on command fail
def force_continue?
  if self.class.const_defined?(:FORCE_CONTINUE)
    self.class::FORCE_CONTINUE
  else
    DEFAULT_FORCE_CONTINUE
  end
end

def scope_commands_block(idx, total, track_tree_mode: default_tree_tracking_mode)

Returns:
  • (Proc, NilClass) - the payload block

Other tags:
    Note: -
def scope_commands_block(idx, total, track_tree_mode: default_tree_tracking_mode)
  case track_tree_mode
  when :per_request
    nil
  when :once
    commands_payload_without_structure_block
  when :per_batch
    return nil if idx == total
    commands_payload_without_structure_block
  end
end