pacecar 1.5.1 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +0 -2
- data/lib/pacecar/associations.rb +1 -1
- data/lib/pacecar/ranking.rb +2 -2
- metadata +3 -3
data/Gemfile
CHANGED
data/lib/pacecar/associations.rb
CHANGED
@@ -31,7 +31,7 @@ module Pacecar
|
|
31
31
|
protected
|
32
32
|
|
33
33
|
def conditions_for_name(name)
|
34
|
-
"((select count(*) from #{connection.quote_table_name(name)} where #{connection.quote_table_name(name)}.#{connection.quote_column_name
|
34
|
+
"((select count(*) from #{connection.quote_table_name(name)} where #{connection.quote_table_name(name)}.#{connection.quote_column_name(reflections[name].respond_to?(:foreign_key) ? reflections[name].foreign_key : reflections[name].primary_key_name)} = #{quoted_table_name}.#{connection.quote_column_name primary_key} and #{connection.quote_table_name(name)}.#{connection.quote_column_name("created_at")} > :since_time) > 0)"
|
35
35
|
end
|
36
36
|
|
37
37
|
end
|
data/lib/pacecar/ranking.rb
CHANGED
@@ -27,7 +27,7 @@ module Pacecar
|
|
27
27
|
|
28
28
|
def define_ranking_scope(association, direction_name, direction)
|
29
29
|
scope "#{direction_name}_#{association}", {
|
30
|
-
:select => "#{quoted_table_name}.*, count(#{reflections[association].quoted_table_name}.#{connection.quote_column_name
|
30
|
+
:select => "#{quoted_table_name}.*, count(#{reflections[association].quoted_table_name}.#{connection.quote_column_name(reflections[association].respond_to?(:foreign_key) ? reflections[association].foreign_key : reflections[association].primary_key_name)}) as #{association}_count",
|
31
31
|
:order => "#{association}_count #{direction}"
|
32
32
|
}.merge(association_group_and_join(association))
|
33
33
|
end
|
@@ -43,7 +43,7 @@ module Pacecar
|
|
43
43
|
|
44
44
|
def association_group_and_join(association_name)
|
45
45
|
{
|
46
|
-
:joins => "inner join #{connection.quote_table_name(association_name)} on #{connection.quote_table_name(association_name)}.#{connection.quote_column_name
|
46
|
+
:joins => "inner join #{connection.quote_table_name(association_name)} on #{connection.quote_table_name(association_name)}.#{connection.quote_column_name(reflections[association_name].respond_to?(:foreign_key) ? reflections[association_name].foreign_key : reflections[association_name].primary_key_name)} = #{quoted_table_name}.#{connection.quote_column_name primary_key}",
|
47
47
|
:group => safe_column_names.collect { |column_name| "#{quoted_table_name}.#{connection.quote_column_name(column_name)}" }.join(', ')
|
48
48
|
}
|
49
49
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pacecar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2011-
|
16
|
+
date: 2011-10-12 00:00:00.000000000Z
|
17
17
|
dependencies: []
|
18
18
|
description: Generated scopes for ActiveRecord classes.
|
19
19
|
email: support@thoughtbot.com
|
@@ -60,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
60
|
version: '0'
|
61
61
|
requirements: []
|
62
62
|
rubyforge_project:
|
63
|
-
rubygems_version: 1.8.
|
63
|
+
rubygems_version: 1.8.11
|
64
64
|
signing_key:
|
65
65
|
specification_version: 3
|
66
66
|
summary: Pacecar adds scope methods to ActiveRecord classes via database column introspection.
|