eager_group 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/eager_group/preloader.rb +12 -22
- data/lib/eager_group/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88912c5696afe9332d53ac15b2365d2e2d7112391672a2cba5db62012876a138
|
4
|
+
data.tar.gz: a18a2d21cd4299a68774f3dbb62556c71f3096b3ebac28bebf7a767a875fc00f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af269ea9b3be9f9a613f56cf14e52a7b183b6d041583f02aa88945f65150f98147ed7271523b9f8ec0d36c622f42ae257f7137e9cf842b381f11cbd7cd6e50bf
|
7
|
+
data.tar.gz: 2878aaefb0b9420b13531927cd46ad47894954c2999fe81d9bf853d7f2255ae97b42df8e56c43a840b5812d71ed1f535c391ccf605fbed99f08ed0769959eab8
|
data/CHANGELOG.md
CHANGED
@@ -31,28 +31,18 @@ module EagerGroup
|
|
31
31
|
association_class = reflection.klass
|
32
32
|
association_class = association_class.instance_exec(*arguments, &definition.scope) if definition.scope
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
polymophic_as_condition(reflection.through_reflection)
|
47
|
-
)
|
48
|
-
.group(foreign_key)
|
49
|
-
.send(definition.aggregation_function, definition.column_name)
|
50
|
-
else
|
51
|
-
aggregate_hash =
|
52
|
-
association_class.where(reflection.foreign_key => record_ids).where(polymophic_as_condition(reflection))
|
53
|
-
.group(reflection.foreign_key)
|
54
|
-
.send(definition.aggregation_function, definition.column_name)
|
55
|
-
end
|
34
|
+
foreign_key, aggregate_hash =
|
35
|
+
if reflection.is_a?(ActiveRecord::Reflection::HasAndBelongsToManyReflection)
|
36
|
+
["#{reflection.join_table}.#{reflection.foreign_key}", @klass.joins(reflection.name)]
|
37
|
+
elsif reflection.through_reflection
|
38
|
+
["#{reflection.through_reflection.name}.#{reflection.through_reflection.foreign_key}", @klass.joins(reflection.name)]
|
39
|
+
else
|
40
|
+
[reflection.foreign_key, association_class]
|
41
|
+
end
|
42
|
+
aggregate_hash = aggregate_hash.where(foreign_key => record_ids)
|
43
|
+
.where(polymophic_as_condition(reflection))
|
44
|
+
.group(foreign_key)
|
45
|
+
.send(definition.aggregation_function, definition.column_name)
|
56
46
|
if definition.need_load_object
|
57
47
|
aggregate_objects = reflection.klass.find(aggregate_hash.values).each_with_object({}) { |o, h| h[o.id] = o }
|
58
48
|
aggregate_hash.keys.each { |key| aggregate_hash[key] = aggregate_objects[aggregate_hash[key]] }
|
data/lib/eager_group/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eager_group
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|