Module: Eco::API::UseCases::GraphQL::Helpers::Location::Command::EndPoints::Optimizations
- Defined in:
- lib/eco/api/usecases/graphql/helpers/location/command/end_points/optimizations.rb
Constant Summary collapse
- DEFAULT_COMMANDS_PER_PAGE =
45
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 ⇒ Symbol
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(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
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/end_points/optimizations.rb', line 48 def commands_payload_without_structure_block proc { clientMutationId ok errors { # rubocop:disable Style/BlockDelimiters details fullMessages } draft { # rubocop:disable Style/BlockDelimiters ___Ecoportal__API__GraphQL__Fragment__LocationDraft } } end |
#commands_per_page ⇒ Object
Prevents each request from timing out
33 34 35 36 37 38 39 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/end_points/optimizations.rb', line 33 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 ⇒ Symbol
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
11 12 13 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/end_points/optimizations.rb', line 11 def default_tree_tracking_mode :per_request # :per_batch @todo per batch/stage is more plausible end |
#force_continue? ⇒ Boolean
Whether to stop or continue on command fail
42 43 44 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/end_points/optimizations.rb', line 42 def force_continue? false end |
#scope_commands_block(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
23 24 25 26 27 28 29 30 |
# File 'lib/eco/api/usecases/graphql/helpers/location/command/end_points/optimizations.rb', line 23 def scope_commands_block(track_tree_mode: default_tree_tracking_mode) case track_tree_mode when :per_request nil when :once, :per_batch commands_payload_without_structure_block end end |