Module: Eco::API::UseCases::GraphQL::Samples::Location::Command::Service::TreeUpdate

Includes:
DSL, Utils::Sftp
Defined in:
lib/eco/api/usecases/graphql/samples/location/command/service/tree_update.rb

Overview

Service to generate the command updates.

Constant Summary collapse

FORCE_CONTINUE =

Whether to stop or continue on command fail

false

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 Language::AuxiliarLogger

#logger

Attributes included from Results

#error, #exception

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 Utils::Sftp

#ensure_remote_empty, #local_folder, #remote_folder, #remote_subfolder, #sftp, #sftp_config, #sftp_download_files, #sftp_env_base_path, #sftp_group_id, #sftp_move_file, #sftp_session, #to_remote_path, #upload, #with_remote_files

Methods included from Language::AuxiliarLogger

#log

Methods included from Results

#page_errors?, #request_results_class, #rescued, #results

Methods included from TrackChangedIds

#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

#processObject



20
21
22
23
24
25
# File 'lib/eco/api/usecases/graphql/samples/location/command/service/tree_update.rb', line 20

def process
  super
ensure
  rescued { re_archive }
  rescued { email_digest('TagTree Update') }
end

#re_archiveObject

Note:

this is an additional necessary step

Before closing, run RE-ARCHIVE: those that where unarchived via archivedToken that should remain archived.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/eco/api/usecases/graphql/samples/location/command/service/tree_update.rb', line 30

def re_archive
  return if simulate?
  stage = :rearchive

  nodes_diff_class.new(
    hash_list(current_tree),
    file_nodes_list,
    original_tree: current_tree,
    logger:        logger
  ).tap do |nodes_diff|
    archive_input = input(nodes_diff.stage_commands(:archive), force_continue: true)
    sliced_batches(
      archive_input,
      desc:            stage,
      track_tree_mode: :once
    ) do |sliced_input, response, page, pages, count, total| # rubocop:disable Metrics/ParameterLists
      page_results = request_results_class.new(sliced_input, response)
      (results[stage] ||= []) << page_results
      self.error ||= page_errors?(page_results, page, pages, count, total, stage: stage)
    end
  end
end