ree_lib 1.0.66 → 1.0.68

Sign up to get free protection for your applications and to get access to all the features.
Files changed (21) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +5 -5
  3. data/lib/ree_lib/packages/ree_actions/spec/ree_actions/dsl_spec.rb +5 -6
  4. data/lib/ree_lib/packages/ree_dao/Package.schema.json +7 -7
  5. data/lib/ree_lib/packages/ree_dao/package/ree_dao/association.rb +15 -31
  6. data/lib/ree_lib/packages/ree_dao/package/ree_dao/association_methods.rb +33 -0
  7. data/lib/ree_lib/packages/ree_dao/package/ree_dao/associations.rb +4 -1
  8. data/lib/ree_lib/packages/ree_dao/package/ree_dao/beans/dao_cache.rb +14 -10
  9. data/lib/ree_lib/packages/ree_dao/package/ree_dao/functions/{load_agg.rb → agg.rb} +5 -3
  10. data/lib/ree_lib/packages/ree_dao/package/ree_dao/functions/build_connection.rb +1 -1
  11. data/lib/ree_lib/packages/ree_dao/package/ree_dao.rb +1 -8
  12. data/lib/ree_lib/packages/ree_dao/schemas/ree_dao/functions/{load_agg.schema.json → agg.schema.json} +3 -3
  13. data/lib/ree_lib/packages/ree_dao/spec/ree_dao/functions/load_agg/{load_agg_benchmark_spec.rb → agg_benchmark_spec.rb} +59 -59
  14. data/lib/ree_lib/packages/ree_dao/spec/ree_dao/functions/load_agg/agg_spec.rb +981 -0
  15. data/lib/ree_lib/packages/ree_dao/spec/ree_dao/functions/load_agg/{ree_dao_load_agg_test.rb → ree_dao_agg_test.rb} +53 -53
  16. data/lib/ree_lib/packages/ree_http/package/ree_http/constants.rb +2 -2
  17. data/lib/ree_lib/packages/ree_http/package/ree_http/functions/build_request.rb +2 -2
  18. data/lib/ree_lib/packages/ree_http/package/ree_http/functions/build_request_executor.rb +2 -2
  19. data/lib/ree_lib/version.rb +1 -1
  20. metadata +8 -7
  21. data/lib/ree_lib/packages/ree_dao/spec/ree_dao/functions/load_agg/load_agg_spec.rb +0 -981
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4afa1450a6827106e39ef7e907de9ce4f490a2cc323bbc59eca1c5cf7386b69
4
- data.tar.gz: 2a7e3858a80590ad65ce462f77d61f1e5d87435fdf9b5528c626ed41a573cb5c
3
+ metadata.gz: a34603f1dd69c0e4eecca51ac58f30e000fd673da8f157901eb085671b7d9e04
4
+ data.tar.gz: ddd8255a1b09641a1d88869e8c664415b44c1a3e8669c907459fd14bcd709743
5
5
  SHA512:
6
- metadata.gz: 6a2d3070cbe58af3289dd89da27004955d4689a2b32758b7dd123288e6fabcc1915571ee6b353cd8edd0beaef8402f9668bf8034742a7ab30359d26b1f7828a3
7
- data.tar.gz: 3eb4943530aa4e658f091ce8d8314032b9b5381828ec04e82686ecea3ec2a6481d56783eb19a8d86a943d3108a846632ff0903ec2a28b164734792f9e20322ae
6
+ metadata.gz: 1e07c24f16571cbdadf18a7f5013a87d488d230663f89524d927dd1998835365293b83e42bce61e8ceac2871762b16102130efe26419e2ef5270bc5ee2597db7
7
+ data.tar.gz: 6ca2018732da00c6205c048bb1011738694174a8b76930973625567db74e6bca9ad86aea6764e503ddb4f915853ce603160e0bd194f229587c018ac7e98cd156
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ree_lib (1.0.66)
4
+ ree_lib (1.0.68)
5
5
  binding_of_caller (~> 1.0.0)
6
6
  i18n (~> 1.12.0)
7
7
  loofah (~> 2.18.0)
@@ -37,10 +37,10 @@ GEM
37
37
  loofah (2.18.0)
38
38
  crass (~> 1.0.2)
39
39
  nokogiri (>= 1.5.9)
40
+ mini_portile2 (2.8.1)
40
41
  msgpack (1.6.0)
41
- nokogiri (1.15.3-x86_64-darwin)
42
- racc (~> 1.4)
43
- nokogiri (1.15.3-x86_64-linux)
42
+ nokogiri (1.13.10)
43
+ mini_portile2 (~> 2.8.0)
44
44
  racc (~> 1.4)
45
45
  oj (3.13.23)
46
46
  pg (1.4.6)
@@ -51,7 +51,7 @@ GEM
51
51
  rack (>= 1.3)
52
52
  rainbow (3.1.1)
53
53
  rake (13.0.6)
54
- ree (1.0.28)
54
+ ree (1.0.29)
55
55
  commander (~> 4.6.0)
56
56
  rexml (3.2.5)
57
57
  roda (3.58.0)
@@ -147,8 +147,8 @@ RSpec.describe ReeActions::DSL, type: [:autoclean] do
147
147
 
148
148
  contract Any, Hash => Integer
149
149
  def call(user_access, attrs)
150
- user = ReeActionsTest::User.new(name: 'John', age: 30)
151
- users_dao.put(user)
150
+ $user = ReeActionsTest::User.new(name: 'John', age: 30)
151
+ users_dao.put($user)
152
152
 
153
153
  Thread.new do
154
154
  users_dao.put(ReeActionsTest::User.new(name: 'Alex', age: 33))
@@ -162,8 +162,7 @@ RSpec.describe ReeActions::DSL, type: [:autoclean] do
162
162
  end.join
163
163
  end.join
164
164
 
165
- $thread_cache = ReeDao::DaoCache.new.instance_variable_get(:@threads)
166
- .dig(Thread.current.object_id, :users)
165
+ $thread_cache = ReeDao::DaoCache.new.get(:users, $user.id)
167
166
 
168
167
  attrs[:user_id]
169
168
  end
@@ -173,7 +172,7 @@ RSpec.describe ReeActions::DSL, type: [:autoclean] do
173
172
  Thread.new do
174
173
  ReeActionsTest::TestAction3.new.call('user_access', {user_id: 1})
175
174
  end.join
176
- expect($thread_cache.keys.count).to_not eq(0)
177
- expect($thread_cache.keys.count).to eq(4)
175
+
176
+ expect($thread_cache).to eq($user.to_h)
178
177
  }
179
178
  end
@@ -33,6 +33,13 @@
33
33
 
34
34
  ],
35
35
  "objects": [
36
+ {
37
+ "name": "agg",
38
+ "schema": "packages/ree_dao/schemas/ree_dao/functions/agg.schema.json",
39
+ "tags": [
40
+ "fn"
41
+ ]
42
+ },
36
43
  {
37
44
  "name": "build_connection",
38
45
  "schema": "packages/ree_dao/schemas/ree_dao/functions/build_connection.schema.json",
@@ -96,13 +103,6 @@
96
103
  "fn"
97
104
  ]
98
105
  },
99
- {
100
- "name": "load_agg",
101
- "schema": "packages/ree_dao/schemas/ree_dao/functions/load_agg.schema.json",
102
- "tags": [
103
- "fn"
104
- ]
105
- },
106
106
  {
107
107
  "name": "one_to_many",
108
108
  "schema": "packages/ree_dao/schemas/ree_dao/functions/one_to_many.schema.json",
@@ -1,6 +1,7 @@
1
1
  module ReeDao
2
2
  class Association
3
3
  include Ree::LinkDSL
4
+ include ReeDao::AssociationMethods
4
5
 
5
6
  link :demodulize, from: :ree_string
6
7
  link :group_by, from: :ree_array
@@ -119,24 +120,21 @@ module ReeDao
119
120
  end
120
121
  end
121
122
 
122
- if ReeDao::Associations.sync_mode?
123
- ReeDao::Associations.new(
124
- parent.agg_caller,
125
- assoc_list,
126
- parent.local_vars,
127
- parent_dao_name,
128
- autoload_children,
129
- **global_opts
130
- ).instance_exec(assoc_list, &block)
123
+ associations = ReeDao::Associations.new(
124
+ parent.agg_caller,
125
+ assoc_list,
126
+ parent.local_vars,
127
+ parent_dao_name,
128
+ autoload_children,
129
+ **global_opts
130
+ )
131
+ parent_dao = find_dao(parent_dao_name, parent.agg_caller)
132
+
133
+ if dao_in_transaction?(parent_dao) || ReeDao::Associations.sync_mode?
134
+ associations.instance_exec(assoc_list, &block)
131
135
  else
132
- threads = ReeDao::Associations.new(
133
- parent.agg_caller,
134
- assoc_list,
135
- parent.local_vars,
136
- parent_dao_name,
137
- autoload_children,
138
- **global_opts
139
- ).instance_exec(assoc_list, &block)
136
+ threads = associations.instance_exec(assoc_list, &block)
137
+
140
138
  threads[:association_threads].map do |association, assoc_type, assoc_name, __opts, block|
141
139
  Thread.new do
142
140
  association.load(assoc_type, assoc_name, **__opts, &block)
@@ -345,20 +343,6 @@ module ReeDao
345
343
  res.all
346
344
  end
347
345
 
348
- def find_dao(assoc_name, parent, scope)
349
- dao_from_name = parent.instance_variable_get("@#{assoc_name}") || parent.instance_variable_get("@#{assoc_name}s")
350
- return dao_from_name if dao_from_name
351
-
352
- raise ArgumentError, "can't find DAO for :#{assoc_name}, provide correct scope or association name" if scope.nil?
353
- return nil if scope.is_a?(Array)
354
-
355
- table_name = scope.first_source_table
356
- dao_from_scope = parent.instance_variable_get("@#{table_name}")
357
- return dao_from_scope if dao_from_scope
358
-
359
- raise ArgumentError, "can't find DAO for :#{assoc_name}, provide correct scope or association name"
360
- end
361
-
362
346
  def method_missing(method, *args, &block)
363
347
  return super if !parent.agg_caller.private_methods(false).include?(method)
364
348
 
@@ -0,0 +1,33 @@
1
+ module ReeDao
2
+ module AssociationMethods
3
+ def self.included(base)
4
+ base.include(InstanceMethods)
5
+ end
6
+
7
+ def self.extended(base)
8
+ base.include(Instance)
9
+ end
10
+
11
+ module InstanceMethods
12
+ def find_dao(assoc_name, parent_caller, scope = nil)
13
+ dao_from_name = parent_caller.instance_variable_get("@#{assoc_name}") || parent_caller.instance_variable_get("@#{assoc_name}s")
14
+ return dao_from_name if dao_from_name
15
+
16
+ raise ArgumentError, "can't find DAO for :#{assoc_name}, provide correct scope or association name" if scope.nil?
17
+ return nil if scope.is_a?(Array)
18
+
19
+ table_name = scope.first_source_table
20
+ dao_from_scope = parent_caller.instance_variable_get("@#{table_name}")
21
+ return dao_from_scope if dao_from_scope
22
+
23
+ raise ArgumentError, "can't find DAO for :#{assoc_name}, provide correct scope or association name"
24
+ end
25
+
26
+ def dao_in_transaction?(dao)
27
+ return false if dao.nil?
28
+
29
+ dao.db.in_transaction?
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,6 +1,7 @@
1
1
  module ReeDao
2
2
  class Associations
3
3
  include Ree::LinkDSL
4
+ include ReeDao::AssociationMethods
4
5
 
5
6
  attr_reader :agg_caller, :list, :local_vars, :only, :except, :parent_dao_name, :autoload_children, :global_opts
6
7
 
@@ -86,7 +87,9 @@ module ReeDao
86
87
  Optblock => Any
87
88
  )
88
89
  def association(assoc_type, assoc_name, __opts, &block)
89
- if self.class.sync_mode?
90
+ parent_dao = find_dao(parent_dao_name, agg_caller)
91
+
92
+ if dao_in_transaction?(parent_dao) || self.class.sync_mode?
90
93
  return if association_is_not_included?(assoc_name) || list.empty?
91
94
 
92
95
  association = Association.new(self, parent_dao_name, list, **global_opts)
@@ -38,11 +38,11 @@ class ReeDao::DaoCache
38
38
  private
39
39
 
40
40
  def get_thread_object_id(thread)
41
- thread.parent == Thread.main ? thread.object_id : get_parent_thread(thread)
41
+ thread == Thread.main ? thread.object_id : get_parent_thread(thread)
42
42
  end
43
43
 
44
44
  def get_parent_thread(thread)
45
- return thread.object_id if thread.parent == Thread.main || thread == Thread.main
45
+ return thread.object_id if thread == Thread.main
46
46
 
47
47
  get_parent_thread(thread.parent)
48
48
  end
@@ -56,22 +56,26 @@ class ReeDao::DaoCache
56
56
  end
57
57
 
58
58
  def add_table_name(table_name)
59
- if !@threads[current_thread_object_id]
60
- @threads[current_thread_object_id] ||= {}
59
+ current_thr_obj_id = current_thread_object_id
60
+
61
+ if !@threads[current_thr_obj_id]
62
+ @threads[current_thr_obj_id] ||= {}
61
63
  end
62
64
 
63
- @threads[current_thread_object_id][table_name] ||= {}
65
+ @threads[current_thr_obj_id][table_name] ||= {}
64
66
  end
65
67
 
66
68
  def add_primary_key(table_name, primary_key)
67
- if !@threads[current_thread_object_id]
68
- @threads[current_thread_object_id] ||= {}
69
+ current_thr_obj_id = current_thread_object_id
70
+
71
+ if !@threads[current_thr_obj_id]
72
+ @threads[current_thr_obj_id] ||= {}
69
73
  end
70
74
 
71
- if !@threads[current_thread_object_id][table_name]
72
- @threads[current_thread_object_id][table_name] ||= {}
75
+ if !@threads[current_thr_obj_id][table_name]
76
+ @threads[current_thr_obj_id][table_name] ||= {}
73
77
  end
74
78
 
75
- @threads[current_thread_object_id][table_name][primary_key] ||= {}
79
+ @threads[current_thr_obj_id][table_name][primary_key] ||= {}
76
80
  end
77
81
  end
@@ -1,9 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class ReeDao::LoadAgg
3
+ class ReeDao::Agg
4
4
  include Ree::FnDSL
5
+ include ReeDao::AssociationMethods
5
6
 
6
- fn :load_agg do
7
+ fn :agg do
7
8
  link :demodulize, from: :ree_string
8
9
  link :underscore, from: :ree_string
9
10
  link "ree_dao/associations", -> { Associations }
@@ -72,8 +73,9 @@ class ReeDao::LoadAgg
72
73
  agg_caller = block.binding.eval("self")
73
74
 
74
75
  associations = Associations.new(agg_caller, list, local_vars, dao_name, **opts).instance_exec(list, &block)
76
+ dao = find_dao(dao_name, agg_caller)
75
77
 
76
- if ReeDao.load_sync_associations_enabled?
78
+ if dao_in_transaction?(dao) || ReeDao.load_sync_associations_enabled?
77
79
  associations
78
80
  else
79
81
  associations[:association_threads].map do |association, assoc_type, assoc_name, opts, block|
@@ -68,7 +68,7 @@ class ReeDao::BuildConnection
68
68
  end
69
69
 
70
70
  if opts[:sql_log_level]
71
- connection.sql_log_level = opts[:sql_log_level]
71
+ connection.sql_log_level = opts[:sql_log_level]
72
72
  end
73
73
 
74
74
  Timeout::timeout(timeout) do
@@ -18,17 +18,10 @@ module ReeDao
18
18
  require_relative "./ree_dao/dsl"
19
19
  require_relative "./ree_dao/thread_parents"
20
20
  require_relative "./ree_dao/aggregate_dsl"
21
+ require_relative "./ree_dao/association_methods"
21
22
  require_relative "./ree_dao/associations"
22
23
  require_relative "./ree_dao/association"
23
24
 
24
- def self.init_cache(thread)
25
- ReeDao::Cache.init_cache(thread)
26
- end
27
-
28
- def self.drop_cache(thread)
29
- ReeDao::Cache.delete_cache(thread)
30
- end
31
-
32
25
  def self.load_sync_associations_enabled?
33
26
  ENV.has_key?("REE_DAO_SYNC_ASSOCIATIONS") && ENV["REE_DAO_SYNC_ASSOCIATIONS"] == "true"
34
27
  end
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "schema_type": "object",
3
3
  "schema_version": "1.1",
4
- "name": "load_agg",
5
- "path": "packages/ree_dao/package/ree_dao/functions/load_agg.rb",
4
+ "name": "agg",
5
+ "path": "packages/ree_dao/package/ree_dao/functions/agg.rb",
6
6
  "mount_as": "fn",
7
- "class": "ReeDao::LoadAgg",
7
+ "class": "ReeDao::Agg",
8
8
  "factory": null,
9
9
  "methods": [
10
10
  {
@@ -2,9 +2,9 @@
2
2
  require 'faker'
3
3
  require 'benchmark'
4
4
 
5
- RSpec.describe :load_agg do
5
+ RSpec.describe :agg do
6
+ link :agg, from: :ree_dao
6
7
  link :build_pg_connection, from: :ree_dao
7
- link :load_agg, from: :ree_dao
8
8
 
9
9
  NUM_OF_USERS = 100
10
10
  ASSOC_COUNT = 10
@@ -14,7 +14,7 @@ RSpec.describe :load_agg do
14
14
  end
15
15
 
16
16
  before :all do
17
- connection = build_pg_connection(ReeDaoLoadAggTest::Db::DB_CONFIG)
17
+ connection = build_pg_connection(ReeDaoAggTest::Db::DB_CONFIG)
18
18
 
19
19
  connection.drop_table(:organizations, cascade: true) if connection.table_exists?(:organizations)
20
20
  connection.drop_table(:users, cascade: true) if connection.table_exists?(:users)
@@ -108,28 +108,28 @@ RSpec.describe :load_agg do
108
108
  connection.disconnect
109
109
  end
110
110
 
111
- require_relative 'ree_dao_load_agg_test'
111
+ require_relative 'ree_dao_agg_test'
112
112
 
113
- class ReeDaoLoadAggTest::UsersAggBenchmark
113
+ class ReeDaoAggTest::AggUsersBenchmark
114
114
  include ReeDao::AggregateDSL
115
115
 
116
- aggregate :users_agg_benchmark do
117
- link :users, from: :ree_dao_load_agg_test
118
- link :organizations, from: :ree_dao_load_agg_test
119
- link :user_passports, from: :ree_dao_load_agg_test
120
- link :books, from: :ree_dao_load_agg_test
121
- link :movies, from: :ree_dao_load_agg_test
122
- link :videogames, from: :ree_dao_load_agg_test
123
- link :hobbies, from: :ree_dao_load_agg_test
124
- link :vinyls, from: :ree_dao_load_agg_test
125
- link :pets, from: :ree_dao_load_agg_test
126
- link :skills, from: :ree_dao_load_agg_test
127
- link :dreams, from: :ree_dao_load_agg_test
128
- link :load_agg, from: :ree_dao
116
+ aggregate :agg_users_benchmark do
117
+ link :users, from: :ree_dao_agg_test
118
+ link :organizations, from: :ree_dao_agg_test
119
+ link :user_passports, from: :ree_dao_agg_test
120
+ link :books, from: :ree_dao_agg_test
121
+ link :movies, from: :ree_dao_agg_test
122
+ link :videogames, from: :ree_dao_agg_test
123
+ link :hobbies, from: :ree_dao_agg_test
124
+ link :vinyls, from: :ree_dao_agg_test
125
+ link :pets, from: :ree_dao_agg_test
126
+ link :skills, from: :ree_dao_agg_test
127
+ link :dreams, from: :ree_dao_agg_test
128
+ link :agg, from: :ree_dao
129
129
  end
130
130
 
131
131
  def call(ids_or_scope)
132
- load_agg(users, ids_or_scope) do
132
+ agg(users, ids_or_scope) do
133
133
  belongs_to :organization
134
134
 
135
135
  has_many :books
@@ -146,21 +146,21 @@ RSpec.describe :load_agg do
146
146
  end
147
147
  end
148
148
 
149
- class ReeDaoLoadAggTest::UsersSyncFetcher
149
+ class ReeDaoAggTest::UsersSyncFetcher
150
150
  include Ree::FnDSL
151
151
 
152
152
  fn :users_sync_fetcher do
153
- link :users, from: :ree_dao_load_agg_test
154
- link :organizations, from: :ree_dao_load_agg_test
155
- link :user_passports, from: :ree_dao_load_agg_test
156
- link :books, from: :ree_dao_load_agg_test
157
- link :movies, from: :ree_dao_load_agg_test
158
- link :videogames, from: :ree_dao_load_agg_test
159
- link :hobbies, from: :ree_dao_load_agg_test
160
- link :vinyls, from: :ree_dao_load_agg_test
161
- link :pets, from: :ree_dao_load_agg_test
162
- link :skills, from: :ree_dao_load_agg_test
163
- link :dreams, from: :ree_dao_load_agg_test
153
+ link :users, from: :ree_dao_agg_test
154
+ link :organizations, from: :ree_dao_agg_test
155
+ link :user_passports, from: :ree_dao_agg_test
156
+ link :books, from: :ree_dao_agg_test
157
+ link :movies, from: :ree_dao_agg_test
158
+ link :videogames, from: :ree_dao_agg_test
159
+ link :hobbies, from: :ree_dao_agg_test
160
+ link :vinyls, from: :ree_dao_agg_test
161
+ link :pets, from: :ree_dao_agg_test
162
+ link :skills, from: :ree_dao_agg_test
163
+ link :dreams, from: :ree_dao_agg_test
164
164
  link :one_to_many, from: :ree_dao
165
165
  link :one_to_one, from: :ree_dao
166
166
  end
@@ -169,7 +169,7 @@ RSpec.describe :load_agg do
169
169
  Or[Sequel::Dataset, ArrayOf[Integer]],
170
170
  Kwargs[
171
171
  include: ArrayOf[Symbol]
172
- ] => ArrayOf[ReeDaoLoadAggTest::User]
172
+ ] => ArrayOf[ReeDaoAggTest::User]
173
173
  )
174
174
  def call(ids_or_scope, include: [])
175
175
  scope = if ids_or_scope.is_a?(Array)
@@ -230,23 +230,23 @@ RSpec.describe :load_agg do
230
230
  end
231
231
  end
232
232
 
233
- let(:users_agg) { ReeDaoLoadAggTest::UsersAggBenchmark.new }
234
- let(:users_sync_fetcher) { ReeDaoLoadAggTest::UsersSyncFetcher.new }
235
-
236
- let(:organizations) { ReeDaoLoadAggTest::Organizations.new }
237
- let(:users) { ReeDaoLoadAggTest::Users.new }
238
- let(:user_passports) { ReeDaoLoadAggTest::UserPassports.new }
239
- let(:books) { ReeDaoLoadAggTest::Books.new }
240
- let(:movies) { ReeDaoLoadAggTest::Movies.new }
241
- let(:videogames) { ReeDaoLoadAggTest::Videogames.new }
242
- let(:hobbies) { ReeDaoLoadAggTest::Hobbies.new }
243
- let(:vinyls) { ReeDaoLoadAggTest::Vinyls.new }
244
- let(:pets) { ReeDaoLoadAggTest::Pets.new }
245
- let(:skills) { ReeDaoLoadAggTest::Skills.new }
246
- let(:dreams) { ReeDaoLoadAggTest::Dreams.new }
233
+ let(:agg_users) { ReeDaoAggTest::AggUsersBenchmark.new }
234
+ let(:users_sync_fetcher) { ReeDaoAggTest::UsersSyncFetcher.new }
235
+
236
+ let(:organizations) { ReeDaoAggTest::Organizations.new }
237
+ let(:users) { ReeDaoAggTest::Users.new }
238
+ let(:user_passports) { ReeDaoAggTest::UserPassports.new }
239
+ let(:books) { ReeDaoAggTest::Books.new }
240
+ let(:movies) { ReeDaoAggTest::Movies.new }
241
+ let(:videogames) { ReeDaoAggTest::Videogames.new }
242
+ let(:hobbies) { ReeDaoAggTest::Hobbies.new }
243
+ let(:vinyls) { ReeDaoAggTest::Vinyls.new }
244
+ let(:pets) { ReeDaoAggTest::Pets.new }
245
+ let(:skills) { ReeDaoAggTest::Skills.new }
246
+ let(:dreams) { ReeDaoAggTest::Dreams.new }
247
247
 
248
248
  before(:each) do
249
- organization = ReeDaoLoadAggTest::Organization.new(name: "Test Org")
249
+ organization = ReeDaoAggTest::Organization.new(name: "Test Org")
250
250
  organizations.put(organization)
251
251
 
252
252
  _users = []
@@ -255,7 +255,7 @@ RSpec.describe :load_agg do
255
255
  puts "Seeding #{NUM_OF_USERS} users..."
256
256
 
257
257
  NUM_OF_USERS.times do
258
- u = ReeDaoLoadAggTest::User.new(
258
+ u = ReeDaoAggTest::User.new(
259
259
  name: Faker::Name.name,
260
260
  age: rand(18..50),
261
261
  organization_id: organization.id
@@ -268,7 +268,7 @@ RSpec.describe :load_agg do
268
268
  _users.each do |user|
269
269
  ASSOC_COUNT.times do
270
270
  books.put(
271
- ReeDaoLoadAggTest::Book.new(
271
+ ReeDaoAggTest::Book.new(
272
272
  title: Faker::Book.title,
273
273
  user_id: user.id
274
274
  )
@@ -277,7 +277,7 @@ RSpec.describe :load_agg do
277
277
 
278
278
  ASSOC_COUNT.times do
279
279
  movies.put(
280
- ReeDaoLoadAggTest::Movie.new(
280
+ ReeDaoAggTest::Movie.new(
281
281
  user_id: user.id,
282
282
  title: Faker::Movie.title
283
283
  )
@@ -286,7 +286,7 @@ RSpec.describe :load_agg do
286
286
 
287
287
  ASSOC_COUNT.times do
288
288
  videogames.put(
289
- ReeDaoLoadAggTest::Videogame.new(
289
+ ReeDaoAggTest::Videogame.new(
290
290
  user_id: user.id,
291
291
  title: Faker::Game.title
292
292
  )
@@ -295,7 +295,7 @@ RSpec.describe :load_agg do
295
295
 
296
296
  ASSOC_COUNT.times do
297
297
  hobbies.put(
298
- ReeDaoLoadAggTest::Hobby.new(
298
+ ReeDaoAggTest::Hobby.new(
299
299
  user_id: user.id,
300
300
  title: Faker::Hobby.activity
301
301
  )
@@ -304,7 +304,7 @@ RSpec.describe :load_agg do
304
304
 
305
305
  ASSOC_COUNT.times do
306
306
  vinyls.put(
307
- ReeDaoLoadAggTest::Vinyl.new(
307
+ ReeDaoAggTest::Vinyl.new(
308
308
  user_id: user.id,
309
309
  title: Faker::Music.band
310
310
  )
@@ -313,7 +313,7 @@ RSpec.describe :load_agg do
313
313
 
314
314
  ASSOC_COUNT.times do
315
315
  pets.put(
316
- ReeDaoLoadAggTest::Pet.new(
316
+ ReeDaoAggTest::Pet.new(
317
317
  user_id: user.id,
318
318
  name: Faker::Creature::Animal.name
319
319
  )
@@ -322,7 +322,7 @@ RSpec.describe :load_agg do
322
322
 
323
323
  ASSOC_COUNT.times do
324
324
  skills.put(
325
- ReeDaoLoadAggTest::Skill.new(
325
+ ReeDaoAggTest::Skill.new(
326
326
  user_id: user.id,
327
327
  title: Faker::Job.key_skill
328
328
  )
@@ -331,7 +331,7 @@ RSpec.describe :load_agg do
331
331
 
332
332
  ASSOC_COUNT.times do
333
333
  dreams.put(
334
- ReeDaoLoadAggTest::Dream.new(
334
+ ReeDaoAggTest::Dream.new(
335
335
  user_id: user.id,
336
336
  description: Faker::ChuckNorris.fact
337
337
  )
@@ -340,7 +340,7 @@ RSpec.describe :load_agg do
340
340
 
341
341
  ASSOC_COUNT.times do
342
342
  user_passports.put(
343
- ReeDaoLoadAggTest::UserPassport.new(
343
+ ReeDaoAggTest::UserPassport.new(
344
344
  user_id: user.id,
345
345
  info: "Passport info #{user.id}"
346
346
  )
@@ -358,12 +358,12 @@ RSpec.describe :load_agg do
358
358
 
359
359
  benchmark_res = Benchmark.bm do |x|
360
360
  x.report("async_load_agg") do
361
- res1 = users_agg.call(users.all.map(&:id))
361
+ res1 = agg_users.call(users.all.map(&:id))
362
362
  end
363
363
 
364
364
  x.report("sync_load_agg ") do
365
365
  ENV['REE_DAO_SYNC_ASSOCIATIONS'] = "true"
366
- res2 = users_agg.call(users.all.map(&:id))
366
+ res2 = agg_users.call(users.all.map(&:id))
367
367
  ENV.delete('REE_DAO_SYNC_ASSOCIATIONS')
368
368
  end
369
369