Module: Eco::API::UseCases::GraphQL::Samples::Location::Service::TreeDiff

Includes:
TreeToList
Defined in:
lib/eco/api/usecases/graphql/samples/location/service/tree_diff.rb,
lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible.rb,
lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/heading.rb,
lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb,
lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/inputable.rb,
lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing/helpers.rb,
lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing/classifications.rb

Overview

IN_FILENAME = /requested_tree.csv/.freeze IN_FOLDER = 'sftp'.freeze HEADER_MAPS = { 'Code' => 'id', 'Description' => 'name', 'ParentCode' => 'parent_id', 'IsActive' => 'active', 'LevelDescription' => 'classifications' }.freeze CLASSIFICATION_MAPS = { 'Directorate' => 'agency', 'Subsection' => 'sub-section', 'WorkUnit' => 'work-unit' }.freeze

def process compare end

private

def custom_input_csv_transform(csv) csv.add_column('archived') end

def custom_input_row_transform(row) row['archived'] = !as_boolean(row['active']) end end

Defined Under Namespace

Modules: Convertible

Constant Summary

Constants included from Eco::API::UseCases::GraphQL::Samples::Location::Service::TreeToList::Converter::Discarded

Eco::API::UseCases::GraphQL::Samples::Location::Service::TreeToList::Converter::Discarded::DISCARDED_NODES

Constants included from Eco::API::UseCases::GraphQL::Samples::Location::Service::TreeToList::Converter::NodeAttrMaps

Eco::API::UseCases::GraphQL::Samples::Location::Service::TreeToList::Converter::NodeAttrMaps::NODE_ATTR_MAPS

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

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

Constants included from Eco::API::UseCases::GraphQL::Samples::Location::Service::TreeToList::Output

Eco::API::UseCases::GraphQL::Samples::Location::Service::TreeToList::Output::OUT_FILENAME, Eco::API::UseCases::GraphQL::Samples::Location::Service::TreeToList::Output::OUT_FOLDER, Eco::API::UseCases::GraphQL::Samples::Location::Service::TreeToList::Output::OUT_HEADER, Eco::API::UseCases::GraphQL::Samples::Location::Service::TreeToList::Output::OUT_TIME_FORMAT

Instance Attribute Summary

Attributes included from Helpers::Base::ErrorHandling

#exception, #exiting

Attributes included from Language::AuxiliarLogger

#logger

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

#current_tree, #previous_tree

Instance Method Summary collapse

Methods included from Helpers::Location::Base

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

Methods included from Language::AuxiliarLogger

#log

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

#backup_tree, #track_current_tree, #track_current_tree?

Instance Method Details

#compareObject



60
61
62
63
64
65
66
# File 'lib/eco/api/usecases/graphql/samples/location/service/tree_diff.rb', line 60

def compare
  comparer.tap do |cmp|
    puts comparer.diffs_details if print_diff_details? && cmp.diffs?
    log(:info) { cmp.diffs_summary }
    sleep(5)
  end
end

#comparer(source_1 = live_nodes_list, source_2 = file_nodes_list) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/eco/api/usecases/graphql/samples/location/service/tree_diff.rb', line 68

def comparer(source_1 = live_nodes_list, source_2 = file_nodes_list)
  @comparer ||= nodes_diff_class.new(
    source_1,
    source_2,
    original_tree: input_tagtree,
    logger:        logger
  ).tap do
    log(:info) {
      "Comparing #{source_1.count} nodes with #{source_2.count} file nodes."
    }
  end
end

#processObject



54
55
56
57
58
# File 'lib/eco/api/usecases/graphql/samples/location/service/tree_diff.rb', line 54

def process
  with_error_handling do
    compare
  end
end