eco-helpers 3.0.6 → 3.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -1
- data/lib/eco/api/usecases/graphql/helpers/base/case_env.rb +1 -0
- data/lib/eco/api/usecases/graphql/helpers/base/error_handling.rb +52 -0
- data/lib/eco/api/usecases/graphql/helpers/base.rb +1 -0
- data/lib/eco/api/usecases/graphql/samples/location/command/dsl.rb +19 -18
- data/lib/eco/api/usecases/graphql/samples/location/command/results.rb +1 -7
- data/lib/eco/api/usecases/graphql/samples/location/command/service/tree_update.rb +9 -6
- data/lib/eco/api/usecases/graphql/samples/location/command/track_changed_ids.rb +2 -8
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible.rb +5 -2
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff.rb +4 -2
- data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list.rb +5 -3
- data/lib/eco/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0fea8f72b2d0037d801b6150661827607326151c71b93df924d1f1271c17166
|
4
|
+
data.tar.gz: d0059328bb938ace9e481a8023a4e5574f1e37e034220418e752c4647de4e382
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01eb1d82295aa464cad0b5898e1fa3a295a7f01953f77b1591a2c1e96a96704f1bf82beb0b41b0ce6b6e0ed6eeea07568e029f2797b62d162dd541d93b37b9ed
|
7
|
+
data.tar.gz: 21258ac597601cad5559f847f26defc78a564733b0e4ed4610d4f70b404cbf6977292a462040374f36706eb69cffabafa52179aa24531c23e29e10a53d9c539b
|
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
-
## [3.0.
|
5
|
+
## [3.0.8] - 2024-08-xx
|
6
6
|
|
7
7
|
### Added
|
8
8
|
|
@@ -10,6 +10,17 @@ All notable changes to this project will be documented in this file.
|
|
10
10
|
|
11
11
|
### Fixed
|
12
12
|
|
13
|
+
## [3.0.7] - 2024-08-27
|
14
|
+
|
15
|
+
### Added
|
16
|
+
|
17
|
+
- `Eco::API::UseCases::GraphQL::Helpers::Base::ErrorHandling`
|
18
|
+
|
19
|
+
### Fixed
|
20
|
+
|
21
|
+
- `Service:TreeUpdate`
|
22
|
+
- Should NOT call `re_archive` when there was a error that is NOT due to an interrupt (i.e. so when raised **error** or `exit`ed)
|
23
|
+
|
13
24
|
## [3.0.6] - 2024-08-26
|
14
25
|
|
15
26
|
### Added
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Eco::API::UseCases::GraphQL::Helpers::Base
|
2
|
+
# Basic stuff you would need in any use case
|
3
|
+
module ErrorHandling
|
4
|
+
include Eco::Language::AuxiliarLogger
|
5
|
+
|
6
|
+
attr_reader :exception
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def interrupted?(err = exception)
|
11
|
+
interrupt_errors.any? {|klass| err.is_a?(klass)}
|
12
|
+
end
|
13
|
+
|
14
|
+
def error_raised?
|
15
|
+
exception && !interrupted?
|
16
|
+
end
|
17
|
+
|
18
|
+
def rescued
|
19
|
+
yield
|
20
|
+
rescue StandardError => err
|
21
|
+
self.exception ||= err
|
22
|
+
log(:error) { err.patch_full_message }
|
23
|
+
end
|
24
|
+
|
25
|
+
def with_error_handling
|
26
|
+
@exception = nil
|
27
|
+
yield
|
28
|
+
rescue SystemExit => sext
|
29
|
+
@exception = sext
|
30
|
+
exit sext.status
|
31
|
+
rescue *interrupt_errors => int
|
32
|
+
@exception = int
|
33
|
+
raise
|
34
|
+
rescue SystemStackError
|
35
|
+
puts $! # rubocop:disable Style/SpecialGlobalVars
|
36
|
+
puts caller[0..100]
|
37
|
+
raise
|
38
|
+
rescue StandardError, SignalException => err
|
39
|
+
@exception = err
|
40
|
+
raise
|
41
|
+
end
|
42
|
+
|
43
|
+
def interrupt_errors
|
44
|
+
return @interrupt_errors if @interrupt_errors
|
45
|
+
|
46
|
+
errs = [Interrupt]
|
47
|
+
errs << IRB::Abort if Object.const_defined?(:IRB) && IRB.const_defined?(:Abort)
|
48
|
+
|
49
|
+
@interrupt_errors = errs
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -24,38 +24,39 @@ class Eco::API::UseCases::GraphQL::Samples::Location
|
|
24
24
|
|
25
25
|
# Main processor
|
26
26
|
def process # rubocop:disable Metrics/AbcSize
|
27
|
-
self.error
|
28
|
-
self.exception = nil
|
27
|
+
self.error = false
|
29
28
|
|
30
|
-
|
29
|
+
with_error_handling do
|
30
|
+
super if defined?(super)
|
31
31
|
|
32
|
-
|
33
|
-
|
32
|
+
# this may trigger a backup of the tagtree
|
33
|
+
self.current_tree ||= live_tree
|
34
34
|
|
35
|
-
|
36
|
-
|
35
|
+
inputs(force_continue: force_continue?) do |input, stage|
|
36
|
+
results[stage] ||= []
|
37
37
|
|
38
|
-
|
38
|
+
track_mode = batch_tree_track_mode(stage)
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
# yields the result of each batch
|
41
|
+
sliced_batches(input, desc: stage, track_tree_mode: track_mode) do |sliced_input, response, page, pages, done, total| # rubocop:disable Metrics/ParameterLists, Layout/LineLength
|
42
|
+
track_current_tree(response&.structure)
|
43
43
|
|
44
|
-
|
45
|
-
|
44
|
+
results[stage] << (page_results = request_results_class.new(sliced_input, response))
|
45
|
+
update_tags_remap_table(page_results, stage, current_tree)
|
46
|
+
|
47
|
+
self.error = page_errors?(page_results, page, pages, done, total, stage: stage)
|
48
|
+
break if error
|
49
|
+
end
|
46
50
|
|
47
|
-
self.error = page_errors?(page_results, page, pages, done, total, stage: stage)
|
48
51
|
break if error
|
49
52
|
end
|
50
|
-
|
51
|
-
break if error
|
52
53
|
end
|
53
54
|
rescue SystemStackError
|
54
55
|
puts $! # rubocop:disable Style/SpecialGlobalVars
|
55
56
|
puts caller[0..100]
|
56
57
|
raise
|
57
|
-
rescue StandardError =>
|
58
|
-
log(:error) {
|
58
|
+
rescue StandardError => err
|
59
|
+
log(:error) { err.patch_full_message }
|
59
60
|
raise
|
60
61
|
ensure
|
61
62
|
rescued { self.tags_remap_csv_file = generate_tags_remap_csv }
|
@@ -3,13 +3,7 @@ class Eco::API::UseCases::GraphQL::Samples::Location
|
|
3
3
|
module Command::Results
|
4
4
|
include Eco::API::UseCases::GraphQL::Helpers::Base::CaseEnv
|
5
5
|
|
6
|
-
attr_accessor :error
|
7
|
-
|
8
|
-
def rescued
|
9
|
-
yield
|
10
|
-
rescue StandardError => e
|
11
|
-
log(:error) { self.exception ||= e.patch_full_message }
|
12
|
-
end
|
6
|
+
attr_accessor :error
|
13
7
|
|
14
8
|
def request_results_class
|
15
9
|
Eco::API::UseCases::GraphQL::Helpers::Location::Command::Results
|
@@ -7,7 +7,7 @@ class Eco::API::UseCases::GraphQL::Samples::Location
|
|
7
7
|
|
8
8
|
class << self
|
9
9
|
def included(base)
|
10
|
-
super
|
10
|
+
super
|
11
11
|
base.send :include, Eco::API::UseCases::GraphQL::Samples::Location::Service::TreeDiff
|
12
12
|
base.send :include, Eco::API::UseCases::GraphQL::Samples::Location::Command::DSL
|
13
13
|
base.send :include, Eco::API::UseCases::GraphQL::Utils::Sftp
|
@@ -17,9 +17,11 @@ class Eco::API::UseCases::GraphQL::Samples::Location
|
|
17
17
|
|
18
18
|
module InstanceMethods
|
19
19
|
def process
|
20
|
-
|
20
|
+
with_error_handling do
|
21
|
+
super
|
22
|
+
end
|
21
23
|
ensure
|
22
|
-
rescued { re_archive }
|
24
|
+
rescued { re_archive } unless error_raised?
|
23
25
|
rescued { email_digest('TagTree Update') }
|
24
26
|
end
|
25
27
|
|
@@ -28,6 +30,7 @@ class Eco::API::UseCases::GraphQL::Samples::Location
|
|
28
30
|
# @note this is an additional necessary step
|
29
31
|
def re_archive
|
30
32
|
return if simulate?
|
33
|
+
return if error_raised?
|
31
34
|
|
32
35
|
stage = :rearchive
|
33
36
|
|
@@ -85,9 +88,9 @@ class Eco::API::UseCases::GraphQL::Samples::Location
|
|
85
88
|
return if simulate?
|
86
89
|
return if options.dig(:workflow, :no_email)
|
87
90
|
|
88
|
-
digest_msgs
|
89
|
-
|
90
|
-
subject
|
91
|
+
digest_msgs = logger.cache.logs(level: %i[info error warn])
|
92
|
+
str_exception = exception ? " - Exception!" : ''
|
93
|
+
subject = "#{config.active_enviro} - #{title}#{str_exception}"
|
91
94
|
session.mail(subject: subject, body: digest_msgs.join)
|
92
95
|
end
|
93
96
|
|
@@ -58,23 +58,17 @@ class Eco::API::UseCases::GraphQL::Samples::Location
|
|
58
58
|
next if prev_id == new_id
|
59
59
|
|
60
60
|
tags_remap_table << [[prev_id], [new_id]]
|
61
|
-
|
62
|
-
# next unless ref_tree.is_a?(Eco::API::Organization::TagTree)
|
63
|
-
# next unless ref_tree.tag?(new_id)
|
64
|
-
|
65
|
-
# msg = "Node '#{prev_id}' was updated to '#{new_id}', "
|
66
|
-
# msg << "but in current structure '#{new_id}' is not present"
|
67
|
-
# log(:warn) { msg }
|
68
61
|
end
|
69
62
|
end
|
70
63
|
|
71
64
|
# Generates the final tags remap file
|
72
65
|
def generate_tags_remap_csv(filename = tags_remap_csv_full_filename)
|
73
|
-
return
|
66
|
+
return if tags_remap_table.empty?
|
74
67
|
|
75
68
|
timestamp_file(filename).tap do |file|
|
76
69
|
CSV.open(file, 'w') do |csv|
|
77
70
|
csv << %w[prev_node_ids new_node_ids]
|
71
|
+
|
78
72
|
tags_remap_table.each do |tags_remap|
|
79
73
|
csv << tags_remap.to_csv_row
|
80
74
|
end
|
@@ -8,7 +8,7 @@ module Eco::API::UseCases::GraphQL::Samples::Location::Service
|
|
8
8
|
module Convertible
|
9
9
|
class << self
|
10
10
|
def included(base)
|
11
|
-
super
|
11
|
+
super
|
12
12
|
base.send :include, Inputable
|
13
13
|
end
|
14
14
|
end
|
@@ -24,12 +24,15 @@ module Eco::API::UseCases::GraphQL::Samples::Location::Service
|
|
24
24
|
|
25
25
|
csv.transform_headers do |name|
|
26
26
|
next name unless header_maps.key?(name)
|
27
|
+
|
27
28
|
header_maps[name]
|
28
29
|
end
|
29
30
|
end.then do |csv|
|
30
31
|
transform_input_csv(csv).tap do |res|
|
31
32
|
next if res.is_a?(Eco::CSV::Table)
|
32
|
-
|
33
|
+
|
34
|
+
msg = "Expecting and Eco::CSV::Table. Given: #{res.class}"
|
35
|
+
raise ArgumentError, msg
|
33
36
|
end
|
34
37
|
end
|
35
38
|
end
|
@@ -46,13 +46,15 @@ module Eco::API::UseCases::GraphQL::Samples
|
|
46
46
|
|
47
47
|
class << self
|
48
48
|
def included(base)
|
49
|
-
super
|
49
|
+
super
|
50
50
|
base.send :include, Convertible
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
54
|
def process
|
55
|
-
|
55
|
+
with_error_handling do
|
56
|
+
compare
|
57
|
+
end
|
56
58
|
end
|
57
59
|
|
58
60
|
def compare
|
@@ -31,10 +31,12 @@ module Eco::API::UseCases::GraphQL::Samples
|
|
31
31
|
include Converter
|
32
32
|
|
33
33
|
def process
|
34
|
-
|
35
|
-
|
34
|
+
with_error_handling do
|
35
|
+
as_nodes_json(input_tagtree).tap do |list|
|
36
|
+
next generate_live_nodes_file(list) unless list.empty?
|
36
37
|
|
37
|
-
|
38
|
+
log(:error) { "There are no location nodes!" }
|
39
|
+
end
|
38
40
|
end
|
39
41
|
end
|
40
42
|
end
|
data/lib/eco/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eco-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar Segura
|
@@ -726,6 +726,7 @@ files:
|
|
726
726
|
- lib/eco/api/usecases/graphql/helpers.rb
|
727
727
|
- lib/eco/api/usecases/graphql/helpers/base.rb
|
728
728
|
- lib/eco/api/usecases/graphql/helpers/base/case_env.rb
|
729
|
+
- lib/eco/api/usecases/graphql/helpers/base/error_handling.rb
|
729
730
|
- lib/eco/api/usecases/graphql/helpers/base/graphql_env.rb
|
730
731
|
- lib/eco/api/usecases/graphql/helpers/location.rb
|
731
732
|
- lib/eco/api/usecases/graphql/helpers/location/base.rb
|