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

Includes:
DSL, Service::TreeDiff, 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

Constants included from Service::TreeDiff::Convertible::Heading

Service::TreeDiff::Convertible::Heading::HEADER_MAPS

Constants included from Service::TreeDiff::Convertible::Parsing::Classifications

Service::TreeDiff::Convertible::Parsing::Classifications::CLASSIFICATION_MAPS

Constants included from Service::TreeToList::Converter::Discarded

Service::TreeToList::Converter::Discarded::DISCARDED_NODES

Constants included from Service::TreeToList::Converter::NodeAttrMaps

Service::TreeToList::Converter::NodeAttrMaps::NODE_ATTR_MAPS

Constants included from Service::TreeToList::Output

Service::TreeToList::Output::OUT_FILENAME, Service::TreeToList::Output::OUT_FOLDER, Service::TreeToList::Output::OUT_HEADER, Service::TreeToList::Output::OUT_TIME_FORMAT

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?

Methods included from Service::TreeDiff

#compare, #comparer

Instance Method Details

#processObject



12
13
14
15
16
17
# File 'lib/eco/api/usecases/graphql/samples/location/command/service/tree_update.rb', line 12

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.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/eco/api/usecases/graphql/samples/location/command/service/tree_update.rb', line 22

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