activegraph-extensions 0.0.2-java → 0.0.4-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c32c0f026083ce5175029f15de509da256e64f55456d29ee5c26358a43694ac
4
- data.tar.gz: 78ce8b9d21c30b326a4314487ac75d6d0b5e449dcf20fe3c9ef6da29f332ce9f
3
+ metadata.gz: 822c83b14e7ebc57f5b13232de171a80a1b954d1c1777853e73299950ddf94b8
4
+ data.tar.gz: 5dd31ca0ddf3cec93e366cab32fc026565045ce8d24680ff2aff10f4df24b4cb
5
5
  SHA512:
6
- metadata.gz: 00bdc4fb09667e26efcc0f376c6e54d566dd2f3ab1fc804f6e24b95da84981060ca920163c9b7c550d2da1bc44a50137beb6be7dad0063bdc1d71581df57ad1c
7
- data.tar.gz: 61f86edaea0e316af6a97190d16dd25d582e1cd96a0778547101db87c520fdff8973fc5e71a2901169eee0ce63730c810aa95a90281a9b9fb6cf680e36c34f8a
6
+ metadata.gz: 58f75afdac57dfe835551242707ba89d248de6f073052e0fb08edb4010e30f24d9f383613ff3c1aa46117a5b35448b5663914971e89cf2b3bb24b2763c3669b2
7
+ data.tar.gz: 9062f2a9c43e2da8b42178c36c6dba95a0b3946a94afbdc56908cd49673548864024e7885becffa6d8686a8798d2333a7d7d3ef858e179291335f35a80502533
data/CHANGELOG.md CHANGED
@@ -1 +1,7 @@
1
- # Change Log
1
+ # Change Log
2
+
3
+ ## [0.0.3] 2023-02-23
4
+
5
+ ## Fixed
6
+
7
+ - Fixed issue where there was 500 error when we are eagerloding relations with multiple optional matches and some privious match was haveing authorization and next one was skipping authorization for those same nodes. This would result in a collection of related nodes where some nodes were null and corresponding next optional match nodes on path had values.
@@ -33,7 +33,6 @@ DESCRIPTION
33
33
  s.add_development_dependency('guard-rspec')
34
34
  s.add_development_dependency('guard-rubocop')
35
35
  s.add_development_dependency('neo4j-rake_tasks', '>= 0.3.0')
36
- # s.add_development_dependency("neo4j-#{ENV['driver'] == 'java' ? 'java' : 'ruby'}-driver", '~> 4.1.0.beta.1')
37
36
  s.add_development_dependency('os')
38
37
  s.add_development_dependency('pry')
39
38
  s.add_development_dependency('railties', '>= 4.0')
@@ -6,25 +6,28 @@ module ActiveGraphExtensions
6
6
  module QueryProxyEagerLoading
7
7
  module AssociationLimiting
8
8
  def self.included(base)
9
- base.attr_reader(:default_assoc_limit)
9
+ base.attr_reader(:max_page_size)
10
+ base.attr_reader(:paginate)
10
11
  end
11
12
 
12
13
  private
13
14
 
14
15
  def rel_collection_str(path)
15
- limit = association_limit(path)
16
16
  collection_name = "[#{relationship_name(path)}, #{escape(path_name(path))}] "
17
- collection = limit.present? ? "apoc.agg.slice(#{collection_name}, 0, #{limit})" : "collect(#{collection_name})"
17
+ collection = apply_limit?(path) ? "apoc.agg.slice(#{collection_name}, 0, #{association_limit(path)})" : "collect(#{collection_name})"
18
18
  "#{collection} AS #{escape("#{path_name(path)}_collection")}"
19
19
  end
20
20
 
21
- def relationship_name(path)
22
- if path.last.rel_length
23
- "last(relationships(#{escape("#{path_name(path)}_path")}))"
24
- else
25
- escape("#{path_name(path)}_rel")
21
+ def apply_limit?(path)
22
+ !multipath?(path) && (path.last&.association_limit || paginate)
26
23
  end
27
24
 
25
+ def relationship_name(path)
26
+ if path.last.rel_length
27
+ "last(relationships(#{escape("#{path_name(path)}_path")}))"
28
+ else
29
+ escape("#{path_name(path)}_rel")
30
+ end
28
31
  end
29
32
 
30
33
  def convert_to_list(collection_name, limit)
@@ -32,10 +35,8 @@ module ActiveGraphExtensions
32
35
  end
33
36
 
34
37
  def association_limit(path)
35
- return if multipath?(path)
36
-
37
38
  limit = path.last&.association_limit
38
- limit.blank? || limit.to_i > default_assoc_limit ? default_assoc_limit : limit
39
+ limit.blank? || limit.to_i > max_page_size ? max_page_size : limit
39
40
  end
40
41
 
41
42
  def with_association_query_part(base_query, path, previous_with_vars)
@@ -45,8 +46,9 @@ module ActiveGraphExtensions
45
46
  end
46
47
 
47
48
  def limit_node_in_where_clause(query, path)
48
- root_path = path[0..0]
49
- query.where("`#{path_name(root_path)}` in [i IN #{node_from_collection(root_path)} | i[1]]")
49
+ (path.length - 1).times.inject(query) do |query_with_where, index|
50
+ query_with_where.where("`#{path_name(path[0..index])}` in [i IN #{node_from_collection(path[0..index])} | i[1]]")
51
+ end
50
52
  end
51
53
 
52
54
  def node_from_collection(path_step)
@@ -35,20 +35,10 @@ module ActiveGraphExtensions
35
35
  end
36
36
 
37
37
  def process_string(str)
38
- # head, rest = str.split('.', 2)
39
- # head, association_limit = extract_assoc_limit(head)
40
- # k, length = head.split('*', -2)
41
- # length = { max: length } if length
42
- #add_nested(k.to_sym, rest, length, association_limit)
43
38
  map = StringParsers::RelationParser.new.parse(str)
44
39
  add_nested(map[:rel_name].to_sym, map[:rest_str].to_s.presence, map[:length_part], map[:limit_digit])
45
40
  end
46
41
 
47
- # def extract_assoc_limit(str)
48
- # transformer = StringParsers::RelationParamTransformer.new(str)
49
- # [transformer.rel_name_n_length, transformer.rel_limit_number]
50
- # end
51
-
52
42
  def process_hash(spec)
53
43
  spec = spec.dup
54
44
  @options = spec.delete(:_options)
@@ -10,10 +10,8 @@ module ActiveGraphExtensions
10
10
  rel_model = relationship_model(path)
11
11
  return {} if @opts.blank? || !(auth_scope = authorized_scope(rel_model, path))
12
12
  conf = { rels: [], chain: {} }
13
- proxy = auth_scope.call(var, "#{var}_rel", user: @opts[:user],
14
- properties: properties_for(rel_model),
15
- privileges: @opts[:privileges],
16
- rel_length: path.last.rel_length)
13
+ proxy = auth_scope.call(var, "#{var}_rel", @opts.merge(properties: properties_for(rel_model),
14
+ rel_length: path.last.rel_length))
17
15
  proxy_rel_parts(proxy.instance_variable_get(:@break_proxy) || proxy, conf)
18
16
  conf
19
17
  end
@@ -12,7 +12,8 @@ module ActiveGraphExtensions
12
12
  end
13
13
 
14
14
  def with_ordered_associations(spec, order, opts = {})
15
- @default_assoc_limit = opts[:default_assoc_limit]
15
+ @max_page_size = opts[:max_page_size]
16
+ @paginate = opts[:paginate]
16
17
  @with_vars = opts[:with_vars]
17
18
  @order_spec = order.with_indifferent_access unless spec.empty?
18
19
  @opts = opts
@@ -57,7 +58,7 @@ module ActiveGraphExtensions
57
58
 
58
59
  def optional_match_with_where(query, path, vars)
59
60
  computed_query = super
60
- computed_query = limit_node_in_where_clause(computed_query, path) if multipath_with_sideload_limit?(path)
61
+ computed_query = limit_node_in_where_clause(computed_query, path) if multipath?(path)
61
62
  skip_order? && !path.last.rel_length ? computed_query : optional_order(computed_query, path, vars)
62
63
  end
63
64
 
@@ -1,3 +1,3 @@
1
1
  module ActiveGraphExtensions
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.4'
3
3
  end
metadata CHANGED
@@ -1,213 +1,213 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activegraph-extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: java
6
6
  authors:
7
7
  - Amit Suryavanshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-23 00:00:00.000000000 Z
11
+ date: 2023-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: parslet
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
16
  - - ">="
18
17
  - !ruby/object:Gem::Version
19
18
  version: '0'
20
- type: :runtime
19
+ name: parslet
21
20
  prerelease: false
21
+ type: :runtime
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: activegraph
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
30
  - - ">="
32
31
  - !ruby/object:Gem::Version
33
32
  version: '0'
34
- type: :runtime
33
+ name: activegraph
35
34
  prerelease: false
35
+ type: :runtime
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: guard
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
44
  - - ">="
46
45
  - !ruby/object:Gem::Version
47
46
  version: '0'
48
- type: :development
47
+ name: guard
49
48
  prerelease: false
49
+ type: :development
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: guard-rspec
57
56
  requirement: !ruby/object:Gem::Requirement
58
57
  requirements:
59
58
  - - ">="
60
59
  - !ruby/object:Gem::Version
61
60
  version: '0'
62
- type: :development
61
+ name: guard-rspec
63
62
  prerelease: false
63
+ type: :development
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: guard-rubocop
71
70
  requirement: !ruby/object:Gem::Requirement
72
71
  requirements:
73
72
  - - ">="
74
73
  - !ruby/object:Gem::Version
75
74
  version: '0'
76
- type: :development
75
+ name: guard-rubocop
77
76
  prerelease: false
77
+ type: :development
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: neo4j-rake_tasks
85
84
  requirement: !ruby/object:Gem::Requirement
86
85
  requirements:
87
86
  - - ">="
88
87
  - !ruby/object:Gem::Version
89
88
  version: 0.3.0
90
- type: :development
89
+ name: neo4j-rake_tasks
91
90
  prerelease: false
91
+ type: :development
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.3.0
97
97
  - !ruby/object:Gem::Dependency
98
- name: os
99
98
  requirement: !ruby/object:Gem::Requirement
100
99
  requirements:
101
100
  - - ">="
102
101
  - !ruby/object:Gem::Version
103
102
  version: '0'
104
- type: :development
103
+ name: os
105
104
  prerelease: false
105
+ type: :development
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: pry
113
112
  requirement: !ruby/object:Gem::Requirement
114
113
  requirements:
115
114
  - - ">="
116
115
  - !ruby/object:Gem::Version
117
116
  version: '0'
118
- type: :development
117
+ name: pry
119
118
  prerelease: false
119
+ type: :development
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: railties
127
126
  requirement: !ruby/object:Gem::Requirement
128
127
  requirements:
129
128
  - - ">="
130
129
  - !ruby/object:Gem::Version
131
130
  version: '4.0'
132
- type: :development
131
+ name: railties
133
132
  prerelease: false
133
+ type: :development
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '4.0'
139
139
  - !ruby/object:Gem::Dependency
140
- name: rake
141
140
  requirement: !ruby/object:Gem::Requirement
142
141
  requirements:
143
142
  - - ">="
144
143
  - !ruby/object:Gem::Version
145
144
  version: '0'
146
- type: :development
145
+ name: rake
147
146
  prerelease: false
147
+ type: :development
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
- name: rubocop
155
154
  requirement: !ruby/object:Gem::Requirement
156
155
  requirements:
157
156
  - - ">="
158
157
  - !ruby/object:Gem::Version
159
158
  version: 0.56.0
160
- type: :development
159
+ name: rubocop
161
160
  prerelease: false
161
+ type: :development
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: 0.56.0
167
167
  - !ruby/object:Gem::Dependency
168
- name: yard
169
168
  requirement: !ruby/object:Gem::Requirement
170
169
  requirements:
171
170
  - - ">="
172
171
  - !ruby/object:Gem::Version
173
172
  version: '0'
174
- type: :development
173
+ name: yard
175
174
  prerelease: false
175
+ type: :development
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  - !ruby/object:Gem::Dependency
182
- name: dryspec
183
182
  requirement: !ruby/object:Gem::Requirement
184
183
  requirements:
185
184
  - - ">="
186
185
  - !ruby/object:Gem::Version
187
186
  version: '0'
188
- type: :development
187
+ name: dryspec
189
188
  prerelease: false
189
+ type: :development
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - ">="
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
195
  - !ruby/object:Gem::Dependency
196
- name: rspec
197
196
  requirement: !ruby/object:Gem::Requirement
198
197
  requirements:
199
198
  - - "<"
200
199
  - !ruby/object:Gem::Version
201
200
  version: '3.10'
202
- type: :development
201
+ name: rspec
203
202
  prerelease: false
203
+ type: :development
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - "<"
207
207
  - !ruby/object:Gem::Version
208
208
  version: '3.10'
209
- description: " Additional features to activegraph, like sideload limiting, authorizing
210
- sideloads etc.\n"
209
+ description: " Additional features to activegraph, like sideload limiting, authorizing\
210
+ \ sideloads etc.\n"
211
211
  email: amitbsuryavabshi@mail.com
212
212
  executables: []
213
213
  extensions: []
@@ -255,7 +255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
255
255
  - !ruby/object:Gem::Version
256
256
  version: '0'
257
257
  requirements: []
258
- rubygems_version: 3.3.7
258
+ rubygems_version: 3.2.29
259
259
  signing_key:
260
260
  specification_version: 4
261
261
  summary: Additional features to activegraph