Add API support for querying admin reports by date range

This commit is contained in:
Robin Ward
2014-11-05 13:11:23 -05:00
parent fde5e739c9
commit 068d22e9b3
5 changed files with 11 additions and 12 deletions

View File

@ -13,8 +13,8 @@ class EmailLog < ActiveRecord::Base
User.where(id: user_id).update_all("last_emailed_at = CURRENT_TIMESTAMP") if user_id.present? and !skipped
end
def self.count_per_day(sinceDaysAgo = 30)
where('created_at > ? and skipped = false', sinceDaysAgo.days.ago).group('date(created_at)').order('date(created_at)').count
def self.count_per_day(start_date, end_date)
where('created_at >= ? and created_at < ? AND skipped = false', start_date, end_date).group('date(created_at)').order('date(created_at)').count
end
def self.for(reply_key)
@ -22,8 +22,7 @@ class EmailLog < ActiveRecord::Base
end
def self.last_sent_email_address
where(email_type: 'signup').order('created_at DESC')
.first.try(:to_address)
where(email_type: 'signup').order('created_at DESC').first.try(:to_address)
end
end