Module: Eco::API::UseCases::GraphQL::Helpers::Location::Command::Optimizations
- Defined in:
 - lib/eco/api/usecases/graphql/helpers/location/command/optimizations.rb
 
Constant Summary collapse
- DEFAULT_COMMANDS_PER_PAGE =
 45- DEFAULT_FORCE_CONTINUE =
 false
Instance Method Summary collapse
- 
  
    
      #commands_payload_without_structure_block  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Commands payload without querying Structure.
 - 
  
    
      #commands_per_page  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Prevents each request from timing out.
 - 
  
    
      #default_tree_tracking_mode  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Available options are: - :per_request -> on each request - :per_batch -> at the end of each batch / stage (on last page) - :once -> only when the script starts to run.
 - 
  
    
      #force_continue?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
Whether to stop or continue on command fail.
 - 
  
    
      #scope_commands_block(idx, total, track_tree_mode: default_tree_tracking_mode)  ⇒ Proc, NilClass 
    
    
  
  
  
  
  
  
  
  
  
    
Helper to identify the commands payload block.
 
Instance Method Details
#commands_payload_without_structure_block ⇒ Object
    Note:
    
  
this servces the purpose of optimizing/speeding up the requests.
Commands payload without querying Structure
      54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82  | 
    
      # File 'lib/eco/api/usecases/graphql/helpers/location/command/optimizations.rb', line 54 def commands_payload_without_structure_block proc { clientMutationId error { # rubocop:disable Style/BlockDelimiters conflictingIds validationErrors { # rubocop:disable Style/BlockDelimiters error } } results { # rubocop:disable Style/BlockDelimiters command { # rubocop:disable Style/BlockDelimiters id state __typename } ok error { # rubocop:disable Style/BlockDelimiters conflictingIds validationErrors { # rubocop:disable Style/BlockDelimiters error } } } } end  | 
  
#commands_per_page ⇒ Object
Prevents each request from timing out
      35 36 37 38 39 40 41  | 
    
      # File 'lib/eco/api/usecases/graphql/helpers/location/command/optimizations.rb', line 35 def commands_per_page if self.class.const_defined?(:COMMANDS_PER_PAGE) self.class::COMMANDS_PER_PAGE else DEFAULT_COMMANDS_PER_PAGE end end  | 
  
#default_tree_tracking_mode ⇒ Object
Available options are:
- :per_request -> on each request
 - :per_batch -> at the end of each batch / stage (on last page)
 - :once -> only when the script starts to run
 
      10 11 12  | 
    
      # File 'lib/eco/api/usecases/graphql/helpers/location/command/optimizations.rb', line 10 def default_tree_tracking_mode :per_request end  | 
  
#force_continue? ⇒ Boolean
Whether to stop or continue on command fail
      44 45 46 47 48 49 50  | 
    
      # File 'lib/eco/api/usecases/graphql/helpers/location/command/optimizations.rb', line 44 def force_continue? if self.class.const_defined?(:FORCE_CONTINUE) self.class::FORCE_CONTINUE else DEFAULT_FORCE_CONTINUE end end  | 
  
#scope_commands_block(idx, total, track_tree_mode: default_tree_tracking_mode) ⇒ Proc, NilClass
    Note:
    
  
- Gives flexibility on at what time the structure should be retrieved
 - This increases performacne, as we don't retrieve the full tree on each request unless necessary/specified
 nilfalls the block back to theecoportal-api-graphqlgem, which has a default block that retrieves the structure
Helper to identify the commands payload block
      22 23 24 25 26 27 28 29 30 31 32  | 
    
      # File 'lib/eco/api/usecases/graphql/helpers/location/command/optimizations.rb', line 22 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  |