ree_lib 1.0.56 → 1.0.57
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 +1 -1
- data/lib/ree_lib/packages/ree_dao/package/ree_dao/associations.rb +2 -0
- data/lib/ree_lib/packages/ree_dao/package/ree_dao/functions/load_agg.rb +3 -1
- data/lib/ree_lib/packages/ree_dao/spec/ree_dao/functions/load_agg/load_agg_spec.rb +49 -12
- 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: 84ad4225d13e31575c1799fd4c7a4b480a1e7ae6b9709834447a733a3a260367
|
4
|
+
data.tar.gz: ba98679b88ac6ad2cec30fcd0280c01638220fdd0a7488f8f33c7ead0dd2de7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccbda33bb5233fc869f470993a93ec1770471e6fdce354a49455bf15c487731b06384bb776ed762c172e75428d77a071fc4483087cdbd2de8ef780729ccae3ac
|
7
|
+
data.tar.gz: d24649974cf1ca2f05c0bece050a7aa91450244cc065f972acacef6f7d966ee52f285c458cf9925d76693b14862d9ebfe77d42142dbb1bea24c3277a26b5a887
|
data/Gemfile.lock
CHANGED
@@ -37,7 +37,9 @@ class ReeDao::LoadAgg
|
|
37
37
|
list = scope.is_a?(Sequel::Dataset) ? scope.all : scope
|
38
38
|
|
39
39
|
if opts[:to_dto]
|
40
|
-
list =
|
40
|
+
list = list.map do |item|
|
41
|
+
list = opts[:to_dto].call(item)
|
42
|
+
end
|
41
43
|
end
|
42
44
|
|
43
45
|
load_associations(list, **opts, &block) if block_given?
|
@@ -275,7 +275,7 @@ RSpec.describe :load_agg do
|
|
275
275
|
load_agg(users, ids_or_scope, **opts) do |agg_list|
|
276
276
|
some_id = agg_list.first.id
|
277
277
|
title = "1984"
|
278
|
-
belongs_to :organization
|
278
|
+
belongs_to :organization, organizations.by_name("Corp")
|
279
279
|
|
280
280
|
has_many :books, -> { books_opts(title) }
|
281
281
|
end
|
@@ -292,6 +292,22 @@ RSpec.describe :load_agg do
|
|
292
292
|
end
|
293
293
|
end
|
294
294
|
|
295
|
+
class ReeDaoLoadAggTest::UsersAggOnlyDataset
|
296
|
+
include ReeDao::AggregateDSL
|
297
|
+
|
298
|
+
aggregate :users_agg_only_dataset do
|
299
|
+
link :users, from: :ree_dao_load_agg_test
|
300
|
+
link :books, from: :ree_dao_load_agg_test
|
301
|
+
link :load_agg, from: :ree_dao
|
302
|
+
end
|
303
|
+
|
304
|
+
def call(ids_or_scope, **opts)
|
305
|
+
load_agg(users, ids_or_scope, **opts) do
|
306
|
+
has_many :books, books.where(title: "1408")
|
307
|
+
end
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
295
311
|
class ReeDaoLoadAggTest::UsersAggWithoutDao
|
296
312
|
include ReeDao::AggregateDSL
|
297
313
|
|
@@ -316,6 +332,7 @@ RSpec.describe :load_agg do
|
|
316
332
|
let(:users_agg_autoload_reviews_children) { ReeDaoLoadAggTest::UsersAggAutoloadReviewsChildren.new }
|
317
333
|
let(:users_agg_without_dao) { ReeDaoLoadAggTest::UsersAggWithoutDao.new }
|
318
334
|
let(:users_agg_with_dto) { ReeDaoLoadAggTest::UsersAggWithDto.new }
|
335
|
+
let(:users_agg_only_dataset) { ReeDaoLoadAggTest::UsersAggOnlyDataset.new }
|
319
336
|
let(:organizations) { ReeDaoLoadAggTest::Organizations.new }
|
320
337
|
let(:users) { ReeDaoLoadAggTest::Users.new }
|
321
338
|
let(:user_passports) { ReeDaoLoadAggTest::UserPassports.new }
|
@@ -354,21 +371,41 @@ RSpec.describe :load_agg do
|
|
354
371
|
|
355
372
|
res = users_agg_with_dto.call(
|
356
373
|
users.all,
|
357
|
-
to_dto: -> (
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
)
|
365
|
-
end
|
374
|
+
to_dto: -> (user) {
|
375
|
+
ReeDaoLoadAggTest::UserDto.new(
|
376
|
+
id: user.id,
|
377
|
+
name: user.name,
|
378
|
+
organization_id: user.organization_id,
|
379
|
+
full_name: user.name
|
380
|
+
)
|
366
381
|
}
|
367
382
|
)
|
368
383
|
|
369
|
-
|
384
|
+
expect(res.first.class).to eq(ReeDaoLoadAggTest::UserDto)
|
385
|
+
}
|
386
|
+
|
387
|
+
it {
|
388
|
+
organizations.delete_all
|
389
|
+
users.delete_all
|
390
|
+
|
391
|
+
org = ReeDaoLoadAggTest::Organization.new(name: "Test Org")
|
392
|
+
organizations.put(org)
|
393
|
+
|
394
|
+
user = ReeDaoLoadAggTest::User.new(name: "John", age: 33, organization_id: org.id)
|
395
|
+
users.put(user)
|
396
|
+
|
397
|
+
book_1 = ReeDaoLoadAggTest::Book.new(user_id: user.id, title: "1984")
|
398
|
+
book_2 = ReeDaoLoadAggTest::Book.new(user_id: user.id, title: "1408")
|
399
|
+
book_3 = ReeDaoLoadAggTest::Book.new(user_id: user.id, title: "1408")
|
400
|
+
|
401
|
+
books.put(book_1)
|
402
|
+
books.put(book_2)
|
403
|
+
books.put(book_3)
|
404
|
+
|
405
|
+
res = users_agg_only_dataset.call(users.where(name: "John"))
|
370
406
|
|
371
|
-
|
407
|
+
user = res[0]
|
408
|
+
expect(user.books.map(&:title).uniq).to eq(["1408"])
|
372
409
|
}
|
373
410
|
|
374
411
|
it {
|
data/lib/ree_lib/version.rb
CHANGED