punching_bag 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,15 +5,15 @@ module PunchingBag
5
5
 
6
6
  # Note: this method will only return items if they have 1 or more hits
7
7
  def most_hit(since=nil, limit=5)
8
- query = self.scoped.joins(:punches).group(:punchable_type, :punchable_id)
8
+ query = self.scoped.joins(:punches).group(Punch.arel_table[:punchable_type], Punch.arel_table[:punchable_id], arel_table.primary_key)
9
9
  query = query.where('punches.average_time >= ?', since) unless since.nil?
10
10
  query.reorder('SUM(punches.hits) DESC').limit(limit)
11
11
  end
12
12
 
13
13
  # Note: this method will return all items with 0 or more hits
14
14
  def sort_by_popularity(dir='DESC')
15
- query = self.scoped.joins("LEFT OUTER JOIN punches ON punches.punchable_id = #{self.to_s.tableize}.id AND punches.punchable_type = '#{self.to_s}'")
16
- query = query.group(:id)
15
+ query = self.scoped.joins(arel_table.join(Punch.arel_table, Arel::Nodes::OuterJoin).on(Punch.arel_table[:punchable_id].eq(arel_table.primary_key).and(Punch.arel_table[:punchable_type].eq(self.name))).join_sources.first)
16
+ query = query.group(arel_table.primary_key)
17
17
  query.reorder("SUM(punches.hits) #{dir}")
18
18
  end
19
19
  end
@@ -1,5 +1,3 @@
1
1
  module PunchingBag
2
-
3
- VERSION = '0.3.1'
4
-
2
+ VERSION = '0.3.2'
5
3
  end
metadata CHANGED
@@ -1,70 +1,88 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: punching_bag
3
- version: !ruby/object:Gem::Version
4
- version: 0.3.1
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 2
10
+ version: 0.3.2
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Adam Crownoble
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-08-02 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2013-06-05 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: voight_kampff
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: 0.1.1
22
- type: :runtime
23
22
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
23
+ requirement: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
- requirements:
25
+ requirements:
27
26
  - - ~>
28
- - !ruby/object:Gem::Version
27
+ - !ruby/object:Gem::Version
28
+ hash: 25
29
+ segments:
30
+ - 0
31
+ - 1
32
+ - 1
29
33
  version: 0.1.1
30
- description: PunchingBag is a hit counting and simple trending engine for Ruby on
31
- Rails
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ description: PunchingBag is a hit counting and simple trending engine for Ruby on Rails
32
37
  email: adam@obledesign.com
33
38
  executables: []
39
+
34
40
  extensions: []
41
+
35
42
  extra_rdoc_files: []
36
- files:
43
+
44
+ files:
37
45
  - app/models/punch.rb
38
- - lib/punching_bag/acts_as_punchable.rb
39
46
  - lib/punching_bag/version.rb
40
47
  - lib/punching_bag/engine.rb
41
48
  - lib/punching_bag/acts_as_taggable_on.rb
49
+ - lib/punching_bag/acts_as_punchable.rb
42
50
  - lib/generators/punching_bag/punching_bag_generator.rb
43
51
  - lib/generators/punching_bag/templates/create_punches_table.rb
44
52
  - lib/punching_bag.rb
45
53
  - lib/tasks/punching_bag.rake
46
54
  homepage: https://github.com/biola/punching_bag
47
55
  licenses: []
56
+
48
57
  post_install_message:
49
58
  rdoc_options: []
50
- require_paths:
59
+
60
+ require_paths:
51
61
  - lib
52
- required_ruby_version: !ruby/object:Gem::Requirement
62
+ required_ruby_version: !ruby/object:Gem::Requirement
53
63
  none: false
54
- requirements:
55
- - - ! '>='
56
- - !ruby/object:Gem::Version
57
- version: '0'
58
- required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ hash: 3
68
+ segments:
69
+ - 0
70
+ version: "0"
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
72
  none: false
60
- requirements:
61
- - - ! '>='
62
- - !ruby/object:Gem::Version
63
- version: '0'
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
79
+ version: "0"
64
80
  requirements: []
81
+
65
82
  rubyforge_project:
66
- rubygems_version: 1.8.24
83
+ rubygems_version: 1.8.25
67
84
  signing_key:
68
85
  specification_version: 3
69
86
  summary: PunchingBag hit conter and trending plugin
70
87
  test_files: []
88
+