Module: Eco::API::UseCases::GraphQL::Samples::Location::Command::DSL

Includes:
Helpers::Location::Command, Results, TrackChangedIds
Included in:
Eco::API::UseCases::GraphQL::Samples::Location::Command
Defined in:
lib/eco/api/usecases/graphql/samples/location/command/dsl.rb

Constant Summary

Constants included from TrackChangedIds

TrackChangedIds::REMAP_LOC_IDS_FILENAME, TrackChangedIds::REMAP_LOC_IDS_FOLDER

Constants included from Helpers::Location::Command::Optimizations

Helpers::Location::Command::Optimizations::DEFAULT_COMMANDS_PER_PAGE, Helpers::Location::Command::Optimizations::DEFAULT_FORCE_CONTINUE

Constants included from Helpers::Location::Base::TreeTracking

Helpers::Location::Base::TreeTracking::TAGTREE_BACKUP

Instance Attribute Summary

Attributes included from Results

#error

Attributes included from Helpers::Base::ErrorHandling

#exception

Attributes included from Language::AuxiliarLogger

#logger

Attributes included from TrackChangedIds

#tags_remap_csv_file

Attributes included from Helpers::Location::Base::TreeTracking

#current_tree, #previous_tree

Instance Method Summary collapse

Methods included from Results

#page_errors?, #request_results_class, #results

Methods included from Language::AuxiliarLogger

#log

Methods included from TrackChangedIds

#close_handling_tags_remap_csv, #generate_tags_remap_csv, #tags_remap_class, #tags_remap_csv_full_filename, #tags_remap_table, #timestamp_file, #update_tags_remap_table

Methods included from Helpers::Location::Command

#apply_commands, #input, #sliced_batches, #with_sliced_input

Methods included from Helpers::Location::Command::Optimizations

#commands_payload_without_structure_block, #commands_per_page, #default_tree_tracking_mode, #force_continue?, #scope_commands_block

Methods included from Helpers::Location::Base

#live_tree, #session_live_tree, #tagtree_id, #target_structure_id, #target_structure_id_const

Methods included from Helpers::Location::Base::TreeTracking

#backup_tree, #track_current_tree, #track_current_tree?

Instance Method Details

#inputs(*_args, force_continue: force_continue?, , **_kargs, &_block) ⇒ Object

Examples:

of implementation:

def inputs(command_types, force_continue: force_continue?)
  {}.tap do |sequence|
    command_types.commands do |comms, stage|
      sequence[stage] = input(comms, force_continue: force_continue)
    end
  end.tap do |sequence|
    sequence.each do |stage, input|
      yield(input, stage) if block_given?
    end
  end
end

Raises:

[View source]

19
20
21
22
23
# File 'lib/eco/api/usecases/graphql/samples/location/command/dsl.rb', line 19

def inputs(*_args, force_continue: force_continue?, **_kargs, &_block) # rubocop:disable Lint/UnusedMethodArgument
  msg  = "You should implement this method in your child class.\n"
  msg << "Which should yield the input Hash and the stage or descriptor."
  raise Eco::API::UseCases::GraphQL::Base::NotImplementedMethod, msg
end

#processObject

Main processor

[View source]

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/eco/api/usecases/graphql/samples/location/command/dsl.rb', line 26

def process # rubocop:disable Metrics/AbcSize
  self.error = false

  with_error_handling do
    super if defined?(super)

    # this may trigger a backup of the tagtree
    self.current_tree ||= live_tree

    inputs(force_continue: force_continue?) do |input, stage|
      results[stage] ||= []

      track_mode = batch_tree_track_mode(stage)

      # yields the result of each batch
      sliced_batches(input, desc: stage, track_tree_mode: track_mode) do |sliced_input, response, page, pages, done, total| # rubocop:disable Metrics/ParameterLists, Layout/LineLength
        track_current_tree(response&.structure)

        results[stage] << (page_results = request_results_class.new(sliced_input, response))
        update_tags_remap_table(page_results, stage, current_tree)

        self.error = page_errors?(page_results, page, pages, done, total, stage: stage)
        break if error
      end

      break if error
    end
  end
rescue SystemStackError
  puts $! # rubocop:disable Style/SpecialGlobalVars
  puts caller[0..100]
  raise
rescue StandardError => err
  log(:error) { err.patch_full_message }
  raise
ensure
  rescued { self.tags_remap_csv_file = generate_tags_remap_csv }
  rescued { close_handling_tags_remap_csv }
end