acts_as_sourceable 2.1.3 → 2.1.4
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.
@@ -30,10 +30,14 @@ module ActsAsSourceable
|
|
30
30
|
scope :sourced, where(options[:cache_column] => true)
|
31
31
|
scope :unsourced, where(options[:cache_column] => false)
|
32
32
|
elsif options[:through]
|
33
|
-
scope :sourced, joins(options[:through]).
|
33
|
+
scope :sourced, joins(options[:through]).group("#{table_name}.#{primary_key}") do
|
34
|
+
include ActsAsSourceable::GroupScopeExtensions
|
35
|
+
end
|
34
36
|
scope :unsourced, joins("LEFT OUTER JOIN (#{sourced.to_sql}) sourced ON sourced.id = #{table_name}.id").where("sourced.id IS NULL")
|
35
37
|
else
|
36
|
-
scope :sourced, joins(:sourceable_registry_entries).
|
38
|
+
scope :sourced, joins(:sourceable_registry_entries).group("#{table_name}.#{primary_key}") do
|
39
|
+
include ActsAsSourceable::GroupScopeExtensions
|
40
|
+
end
|
37
41
|
scope :unsourced, joins("LEFT OUTER JOIN (#{ActsAsSourceable::RegistryEntry.select('sourceable_id AS id').where(:sourceable_type => self).to_sql}) sourced ON sourced.id = #{table_name}.id").where("sourced.id IS NULL")
|
38
42
|
end
|
39
43
|
|
@@ -83,6 +87,13 @@ module ActsAsSourceable
|
|
83
87
|
end
|
84
88
|
end
|
85
89
|
|
90
|
+
module GroupScopeExtensions
|
91
|
+
# Extension for scopes where we're grouping but want to be able to call count
|
92
|
+
def count
|
93
|
+
connection.select_value("SELECT count(1) FROM (#{to_sql}) AS count_all").to_i
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
86
97
|
module ClassMethods
|
87
98
|
def acts_like_sourceable?
|
88
99
|
true
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_sourceable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-02-
|
13
|
+
date: 2013-02-13 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: Allows the RRN to perform garbage collection on categories that are no
|
16
16
|
longer referenced.
|