Permalink
Browse files

Modify most wanted query

  • Loading branch information...
1 parent 2f12cf9 commit 5f93681622feda308a24ea7d3175511f48eedd62 @zuhao committed Aug 9, 2012
Showing with 4 additions and 2 deletions.
  1. +4 −2 app/models/ruby_gem.rb
View
@@ -5,8 +5,10 @@ class RubyGem < ActiveRecord::Base
has_one :fedora_rpm, :dependent => :destroy
has_many :gem_comments, :dependent => :destroy, :order => 'created_at desc'
has_many :dependencies, :as => :package, :dependent => :destroy, :order => 'created_at desc'
- scope :most_wanted, :joins => :gem_comments, :group => 'gem_comments.ruby_gem_id',
- :order => 'count(gem_comments.want_it) desc', :having => 'gem_comments.want_it = "t"'
+ scope :most_wanted, { :joins => 'INNER JOIN gem_comments ON gem_comments.ruby_gem_id = ruby_gems.id',
+ :conditions => 'gem_comments.want_it = "t"',
+ :group => 'ruby_gems.id',
+ :order => 'count(gem_comments.id) desc' }
scope :most_popular, :order => 'downloads desc'
def to_param

0 comments on commit 5f93681

Please sign in to comment.