ree_lib 1.0.50 → 1.0.51
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/Gemfile.lock +4 -2
- data/lib/ree_lib/packages/ree_dao/package/ree_dao/associations.rb +2 -2
- data/lib/ree_lib/packages/ree_dao/package/ree_dao/functions/load_agg.rb +6 -2
- data/lib/ree_lib/packages/ree_dao/spec/ree_dao/functions/load_agg/load_agg_spec.rb +26 -1
- data/lib/ree_lib/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: 11c4d5cf16a6bfdbea763761f5f4a1c993d15b0fe5e912e257df949d5d6a9fd2
|
|
4
|
+
data.tar.gz: 1254d959c594b4b5cbf71c13c04304910648e937ca946c37bfe21dfb32593463
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 36d76d580636a9990a1a691685931e987eb3f9e6cb0ca9f5bcc8759f4bdb1a6c542bcc24768272abec7c7c84f0828508904d49cc988b92fcf9337207259f4e78
|
|
7
|
+
data.tar.gz: 752394c6296ae13cfb4a8d963b0aeaff3de295863c5c48271001c2227a509b371bc264bd1a0942bf2de59b9786f5620ce2053f8e2518e721180c7f27c81ced23
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
ree_lib (1.0.
|
|
4
|
+
ree_lib (1.0.51)
|
|
5
5
|
binding_of_caller (~> 1.0.0)
|
|
6
6
|
i18n (~> 1.12.0)
|
|
7
7
|
loofah (~> 2.18.0)
|
|
@@ -38,12 +38,14 @@ GEM
|
|
|
38
38
|
crass (~> 1.0.2)
|
|
39
39
|
nokogiri (>= 1.5.9)
|
|
40
40
|
msgpack (1.6.0)
|
|
41
|
+
nokogiri (1.15.2-x86_64-darwin)
|
|
42
|
+
racc (~> 1.4)
|
|
41
43
|
nokogiri (1.15.2-x86_64-linux)
|
|
42
44
|
racc (~> 1.4)
|
|
43
45
|
oj (3.13.23)
|
|
44
46
|
pg (1.4.6)
|
|
45
47
|
public_suffix (5.0.1)
|
|
46
|
-
racc (1.
|
|
48
|
+
racc (1.7.1)
|
|
47
49
|
rack (3.0.5)
|
|
48
50
|
rack-test (2.0.2)
|
|
49
51
|
rack (>= 1.3)
|
|
@@ -105,12 +105,12 @@ module ReeDao
|
|
|
105
105
|
)
|
|
106
106
|
def association(assoc_type, assoc_name, **assoc_opts, &block)
|
|
107
107
|
if self.class.sync_mode?
|
|
108
|
-
return if association_is_not_included?(assoc_name)
|
|
108
|
+
return if association_is_not_included?(assoc_name) || list.empty?
|
|
109
109
|
|
|
110
110
|
association = Association.new(self, list, **global_opts)
|
|
111
111
|
association.load(assoc_type, assoc_name, **assoc_opts, &block)
|
|
112
112
|
else
|
|
113
|
-
return @threads if association_is_not_included?(assoc_name)
|
|
113
|
+
return @threads if association_is_not_included?(assoc_name) || list.empty?
|
|
114
114
|
|
|
115
115
|
@threads << Thread.new do
|
|
116
116
|
association = Association.new(self, list, **global_opts)
|
|
@@ -47,6 +47,8 @@ class ReeDao::LoadAgg
|
|
|
47
47
|
private
|
|
48
48
|
|
|
49
49
|
def load_associations(list, **opts, &block)
|
|
50
|
+
return if list.empty?
|
|
51
|
+
|
|
50
52
|
local_vars = block.binding.eval(<<-CODE, __FILE__, __LINE__ + 1)
|
|
51
53
|
vars = self.instance_variables
|
|
52
54
|
vars.reduce({}) { |hsh, var| hsh[var] = self.instance_variable_get(var); hsh }
|
|
@@ -54,10 +56,12 @@ class ReeDao::LoadAgg
|
|
|
54
56
|
|
|
55
57
|
agg_caller = block.binding.eval("self")
|
|
56
58
|
|
|
59
|
+
associations = Associations.new(agg_caller, list, local_vars, **opts).instance_exec(list, &block)
|
|
60
|
+
|
|
57
61
|
if ReeDao.load_sync_associations_enabled?
|
|
58
|
-
|
|
62
|
+
associations
|
|
59
63
|
else
|
|
60
|
-
|
|
64
|
+
associations.map(&:join)
|
|
61
65
|
end
|
|
62
66
|
end
|
|
63
67
|
end
|
|
@@ -203,7 +203,8 @@ RSpec.describe :load_agg do
|
|
|
203
203
|
end
|
|
204
204
|
|
|
205
205
|
def call(ids_or_scope, **opts)
|
|
206
|
-
load_agg(ids_or_scope, users, **opts) do
|
|
206
|
+
load_agg(ids_or_scope, users, **opts) do |agg_list|
|
|
207
|
+
some_id = agg_list.first.id
|
|
207
208
|
title = "1984"
|
|
208
209
|
belongs_to :organization
|
|
209
210
|
|
|
@@ -348,6 +349,30 @@ RSpec.describe :load_agg do
|
|
|
348
349
|
expect(res_user.books.count).to eq(1)
|
|
349
350
|
}
|
|
350
351
|
|
|
352
|
+
it {
|
|
353
|
+
organizations.delete_all
|
|
354
|
+
users.delete_all
|
|
355
|
+
books.delete_all
|
|
356
|
+
|
|
357
|
+
organization = ReeDaoLoadAggTest::Organization.new(name: "Test Org")
|
|
358
|
+
organizations.put(organization)
|
|
359
|
+
|
|
360
|
+
user_1 = ReeDaoLoadAggTest::User.new(name: "John", age: 33, organization_id: organization.id)
|
|
361
|
+
user_2 = ReeDaoLoadAggTest::User.new(name: "Sam", age: 21, organization_id: organization.id)
|
|
362
|
+
users.put(user_1)
|
|
363
|
+
users.put(user_2)
|
|
364
|
+
|
|
365
|
+
book_1 = ReeDaoLoadAggTest::Book.new(user_id: user_1.id, title: "1984")
|
|
366
|
+
book_2 = ReeDaoLoadAggTest::Book.new(user_id: user_1.id, title: "1408")
|
|
367
|
+
|
|
368
|
+
books.put(book_1)
|
|
369
|
+
books.put(book_2)
|
|
370
|
+
|
|
371
|
+
expect {
|
|
372
|
+
users_agg_scope_method.call(users.where(name: "Another names"))
|
|
373
|
+
}.to_not raise_error
|
|
374
|
+
}
|
|
375
|
+
|
|
351
376
|
it {
|
|
352
377
|
organizations.delete_all
|
|
353
378
|
users.delete_all
|
data/lib/ree_lib/version.rb
CHANGED