eco-helpers 2.7.8 → 2.7.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -1
- data/lib/eco/api/usecases/graphql/helpers/location/command/diff/as_update.rb +3 -1
- data/lib/eco/data/locations/node_diff/accessors.rb +2 -2
- data/lib/eco/data/locations/node_diff/nodes_diff/selectors.rb +3 -2
- data/lib/eco/data/locations/node_diff/nodes_diff.rb +30 -0
- data/lib/eco/data/locations/node_diff.rb +9 -0
- data/lib/eco/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41e63439f7a3d89c5e3c9e10be328b9487ecffe4dde6a83a6fd6f9a561d924a8
|
4
|
+
data.tar.gz: bafc6c443ce57b2611c177b00eca9aca0fd06718712511eb2b93762ff957179b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0094ce51df0b47838a44b679fe82a4acacfc64953edeea38ef2c51b6efeb08f0629f019751b319542dddcac5e77838786cdd1b7333b16babb0bf02ad4e197fb3'
|
7
|
+
data.tar.gz: ee5243547b98cdeabba4cf1fdbbd8759b0f24d1e5ea4f4e42b998569ebe0c00bf3d5139ef2c28886bfa96efe6cd7e65344245b4eb6d7c9bb0a08964d075ddd12
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
-
## [2.7.
|
4
|
+
## [2.7.10] - 2024-05-xx
|
5
5
|
|
6
6
|
### Added
|
7
7
|
### Changed
|
8
8
|
### Fixed
|
9
9
|
|
10
|
+
## [2.7.9] - 2024-05-16
|
11
|
+
|
12
|
+
### Fixed
|
13
|
+
- `Eco::Data::Locations::NodeDiff::NodesDiff#unarchive`
|
14
|
+
- It must include archived nodes that will receive new children
|
15
|
+
|
10
16
|
## [2.7.8] - 2024-05-16
|
11
17
|
|
12
18
|
### Added
|
@@ -35,8 +35,10 @@ class Eco::API::UseCases::GraphQL::Helpers::Location::Command::Diff
|
|
35
35
|
h['parentId'] = after_id_update ? parent_id : parent_id_prev
|
36
36
|
end
|
37
37
|
else
|
38
|
+
return h if marked_for_unarchive?
|
39
|
+
|
38
40
|
# Something is wrong (not expected to be any other category)
|
39
|
-
raise "
|
41
|
+
raise "Please review code base, unexpected condition for #{h.pretty_inspect}"
|
40
42
|
end
|
41
43
|
end
|
42
44
|
end
|
@@ -20,8 +20,8 @@ class Eco::Data::Locations::NodeDiff
|
|
20
20
|
def attr_expose(*attrs)
|
21
21
|
attrs.each do |attr|
|
22
22
|
meth = attr.to_sym
|
23
|
-
methp = "#{meth}_prev"
|
24
|
-
methq = "#{meth}?"
|
23
|
+
methp = :"#{meth}_prev"
|
24
|
+
methq = :"#{meth}?"
|
25
25
|
|
26
26
|
# current value
|
27
27
|
define_method meth do
|
@@ -5,8 +5,9 @@ class Eco::Data::Locations::NodeDiff::NodesDiff
|
|
5
5
|
# @note the selector method name with a question mark should exist in the `diff_result_class`
|
6
6
|
def selector(*attrs)
|
7
7
|
attrs.each do |attr|
|
8
|
-
meth
|
9
|
-
methq = "#{meth}?"
|
8
|
+
meth = attr.to_sym
|
9
|
+
methq = :"#{meth}?"
|
10
|
+
|
10
11
|
define_method meth do
|
11
12
|
diffs.select(&methq)
|
12
13
|
end
|
@@ -21,6 +21,7 @@ class Eco::Data::Locations::NodeDiff
|
|
21
21
|
def initialize(*args, original_tree:, **kargs, &block)
|
22
22
|
super(*args, **kargs, &block)
|
23
23
|
@original_tree = original_tree
|
24
|
+
mark_implicit_unarchive!
|
24
25
|
end
|
25
26
|
|
26
27
|
def diffs
|
@@ -95,6 +96,14 @@ class Eco::Data::Locations::NodeDiff
|
|
95
96
|
msg.compact.join("\n")
|
96
97
|
end
|
97
98
|
|
99
|
+
alias_method :unarchive_src, :unarchive
|
100
|
+
|
101
|
+
# @note we must unarchive destination parents that will get
|
102
|
+
# some children as well
|
103
|
+
def unarchive
|
104
|
+
unarchive_src | @implicit_unarchive
|
105
|
+
end
|
106
|
+
|
98
107
|
private
|
99
108
|
|
100
109
|
def when_present(list, default = nil)
|
@@ -103,5 +112,26 @@ class Eco::Data::Locations::NodeDiff
|
|
103
112
|
return yield(count) if count&.positive?
|
104
113
|
default
|
105
114
|
end
|
115
|
+
|
116
|
+
def mark_implicit_unarchive!
|
117
|
+
@implicit_unarchive = source_results.select do |result|
|
118
|
+
result.archived_prev && implicit_unarchive?(result)
|
119
|
+
end.tap do |results|
|
120
|
+
results.each(&:unarchive!)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def implicit_unarchive?(result)
|
125
|
+
[result.node_id, result.node_id_prev].compact.any? do |id|
|
126
|
+
target_parent_ids.include?(id)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def target_parent_ids
|
131
|
+
return @target_parent_ids if instance_variable_defined?(:@target_parent_ids)
|
132
|
+
|
133
|
+
@target_parent_ids = insert.map(&:parent_id).uniq
|
134
|
+
@target_parent_ids |= move.map(&:parent_id)
|
135
|
+
end
|
106
136
|
end
|
107
137
|
end
|
@@ -59,8 +59,17 @@ module Eco::Data::Locations
|
|
59
59
|
parent_id?
|
60
60
|
end
|
61
61
|
|
62
|
+
def unarchive!
|
63
|
+
@marked_for_unarchived = true
|
64
|
+
end
|
65
|
+
|
66
|
+
def marked_for_unarchive?
|
67
|
+
@marked_for_unarchived || false
|
68
|
+
end
|
69
|
+
|
62
70
|
# Has the `archived` property changed and it was `true`?
|
63
71
|
def unarchive?
|
72
|
+
return true if marked_for_unarchive?
|
64
73
|
return false if archived
|
65
74
|
return false unless update?
|
66
75
|
archived?
|
data/lib/eco/version.rb
CHANGED