VRFS-1576 added block to referrals_by_date

This commit is contained in:
Jonathan Kolyer 2014-04-23 06:34:21 +00:00
parent c66f5879cf
commit 22566f1b29
1 changed files with 2 additions and 1 deletions

View File

@ -33,11 +33,12 @@ class JamRuby::AffiliatePartner < ActiveRecord::Base
end
def referrals_by_date
User.where(:affiliate_referral_id => self.id)
by_date = User.where(:affiliate_referral_id => self.id)
.group('DATE(created_at)')
.having("COUNT(*) > 0")
.order('date_created_at DESC')
.count
block_given? ? yield(by_date) : by_date
end
end