eager_group 0.9.0 → 0.9.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/active_record/with_eager_group.rb +11 -1
- data/lib/eager_group/preloader/aggregation_finder.rb +4 -0
- data/lib/eager_group/preloader.rb +3 -5
- data/lib/eager_group/version.rb +1 -1
- data/lib/eager_group.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: 119ff48ee90c0324a8e7f55e521a3606485ad1728ec27eaefea3df1f7c153173
|
4
|
+
data.tar.gz: 7415661b2a4ced20c7673c8d90bfb977fbef22c203062f0bb60a8be5fdd1970a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3b85835d577315809f1a699c7a717d17b1f61c14ae0e0371312c12615a5088c45a266028fc3f091801639298e9dd6a1ca1e8d6beb37889a6f5e63aacbdc8fe6
|
7
|
+
data.tar.gz: 2475f41755b2b0161bcc4fe01fd04a5cb1b9f69728edd0e165e8596773306e421426efc191aa34eba812912c1e6b8cc608386a3fc29ca490a068c15b2335e337
|
data/CHANGELOG.md
CHANGED
@@ -9,7 +9,10 @@ module ActiveRecord
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def eager_group(*args)
|
12
|
-
check_if_method_has_arguments
|
12
|
+
# we does not use the `check_if_method_has_arguments!` here because it would flatten all the arguments,
|
13
|
+
# which would cause `[:eager_group_definition, scope_arg1, scope_arg2]` not able to preload together with other `eager_group_definitions`.
|
14
|
+
# e.g. `Post.eager_group(:approved_comments_count, [:comments_average_rating_by_author, students[0], true])`
|
15
|
+
check_argument_not_blank!(args)
|
13
16
|
|
14
17
|
spawn.eager_group!(*args)
|
15
18
|
end
|
@@ -28,5 +31,12 @@ module ActiveRecord
|
|
28
31
|
|
29
32
|
@values[:eager_group] = values
|
30
33
|
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def check_argument_not_blank!(args)
|
38
|
+
raise ArgumentError, "The method .eager_group() must contain arguments." if args.blank?
|
39
|
+
args.compact_blank!
|
40
|
+
end
|
31
41
|
end
|
32
42
|
end
|
@@ -11,8 +11,7 @@ module EagerGroup
|
|
11
11
|
def initialize(klass, records, eager_group_values)
|
12
12
|
@klass = klass
|
13
13
|
@records = Array.wrap(records).compact.uniq
|
14
|
-
|
15
|
-
@eager_group_values = eager_group_values.all? { |value| eager_group_definitions.key?(value) } ? eager_group_values : [eager_group_values]
|
14
|
+
@eager_group_values = eager_group_values
|
16
15
|
end
|
17
16
|
|
18
17
|
# Preload aggregate functions
|
@@ -27,11 +26,10 @@ module EagerGroup
|
|
27
26
|
next if @records.empty?
|
28
27
|
|
29
28
|
@klass = @records.first.class
|
29
|
+
self.class.new(@klass, @records, Array.wrap(definition_key)).run
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
find_aggregate_values_per_definition!(key, arguments)
|
34
|
-
end
|
32
|
+
find_aggregate_values_per_definition!(definition_key, arguments)
|
35
33
|
end
|
36
34
|
end
|
37
35
|
|
data/lib/eager_group/version.rb
CHANGED
data/lib/eager_group.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.9.
|
4
|
+
version: 0.9.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: 2022-12-
|
11
|
+
date: 2022-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|