Module: Eco::API::UseCases::GraphQL::Samples::Location::Command::TrackChangedIds
- Includes:
- Helpers::Base::CaseEnv
- Included in:
- DSL
- Defined in:
- lib/eco/api/usecases/graphql/samples/location/command/track_changed_ids.rb
Overview
Logic to: Create tags remap csv table batch design
Constant Summary collapse
- REMAP_LOC_IDS_FOLDER =
'cache'.freeze
- REMAP_LOC_IDS_FILENAME =
'remap_loc_ids.csv'.freeze
Instance Attribute Summary collapse
-
#tags_remap_csv_file ⇒ Object
Returns the value of attribute tags_remap_csv_file.
Attributes included from Lib::ErrorHandling
Attributes included from Language::AuxiliarLogger
Instance Method Summary collapse
-
#close_handling_tags_remap_csv ⇒ Object
Generates the file.
-
#generate_tags_remap_csv(filename = tags_remap_csv_full_filename) ⇒ Object
Generates the final tags remap file.
- #tags_remap_class ⇒ Object
- #tags_remap_csv_full_filename ⇒ Object
-
#tags_remap_table ⇒ Array<Array>
The maps of tags to be used in batch remap tags.
-
#timestamp_file(filename, enviro_relative: true) ⇒ Object
Makes the file relative to the enviro.
-
#update_tags_remap_table(command) ⇒ Boolean
Based on commands that succeded, and the batch stage, it tracks the tag remaps that should be batches against existing pages.
Methods included from Language::AuxiliarLogger
Instance Attribute Details
#tags_remap_csv_file ⇒ Object
Returns the value of attribute tags_remap_csv_file.
6 7 8 |
# File 'lib/eco/api/usecases/graphql/samples/location/command/track_changed_ids.rb', line 6 def @tags_remap_csv_file end |
Instance Method Details
#close_handling_tags_remap_csv ⇒ Object
this method used to only work if we could run cummulative dry-runs to the back-end. However, after RS P3, as mappings are one-to-one (not many-to-many per row), we can just display the mappings in dry-run as well.
Generates the file
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/eco/api/usecases/graphql/samples/location/command/track_changed_ids.rb', line 31 def # rubocop:disable Naming/PredicateMethod if .any? puts "REMAP LOC IDs CSV (content):" puts true else log(:info) { "Remap location ids NOT needed :)" } false end end |
#generate_tags_remap_csv(filename = tags_remap_csv_full_filename) ⇒ Object
Generates the final tags remap file
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/eco/api/usecases/graphql/samples/location/command/track_changed_ids.rb', line 57 def (filename = ) return if .empty? (filename).tap do |file| CSV.open(file, 'w') do |csv| csv << %w[prev_node_ids new_node_ids] .each do || csv << .to_csv_row end end log(:info) { "Generated file '#{file}'" } end end |
#tags_remap_class ⇒ Object
17 18 19 |
# File 'lib/eco/api/usecases/graphql/samples/location/command/track_changed_ids.rb', line 17 def Eco::API::UseCases::GraphQL::Helpers::Location::TagsRemap end |
#tags_remap_csv_full_filename ⇒ Object
11 12 13 14 15 |
# File 'lib/eco/api/usecases/graphql/samples/location/command/track_changed_ids.rb', line 11 def folder = self.class::REMAP_LOC_IDS_FOLDER filename = self.class::REMAP_LOC_IDS_FILENAME File.join(folder, filename) end |
#tags_remap_table ⇒ Array<Array>
The maps of tags to be used in batch remap tags
23 24 25 |
# File 'lib/eco/api/usecases/graphql/samples/location/command/track_changed_ids.rb', line 23 def @tags_remap_table ||= .new end |
#timestamp_file(filename, enviro_relative: true) ⇒ Object
Makes the file relative to the enviro
73 74 75 76 |
# File 'lib/eco/api/usecases/graphql/samples/location/command/track_changed_ids.rb', line 73 def (filename, enviro_relative: true) filename = session.file_manager.dir.file(filename) if enviro_relative Eco::Data::Files.(filename) end |
#update_tags_remap_table(command) ⇒ Boolean
The only update operation that generate tag remaps
is :id (or :id_name).
Based on commands that succeded, and the batch stage, it tracks the tag remaps that should be batches against existing pages
47 48 49 50 51 52 53 54 |
# File 'lib/eco/api/usecases/graphql/samples/location/command/track_changed_ids.rb', line 47 def (command) prev_id, new_id = command.values_at(:nodeId, :newId) return if new_id.nil? # not an id change return if prev_id == new_id << [[prev_id], [new_id]] end |