mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 19:39:30 +08:00
Add API support for querying admin reports by date range
This commit is contained in:
@ -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
|
||||
|
@ -39,8 +39,8 @@ class Report
|
||||
# Load the report
|
||||
report = Report.new(type)
|
||||
|
||||
report.start_date = opts[:start_date]
|
||||
report.end_date = opts[:end_date]
|
||||
report.start_date = opts[:start_date] if opts[:start_date]
|
||||
report.end_date = opts[:end_date] if opts[:end_date]
|
||||
send(report_method, report)
|
||||
report
|
||||
end
|
||||
@ -70,7 +70,7 @@ class Report
|
||||
end
|
||||
|
||||
def self.report_about(report, subject_class, report_method = :count_per_day)
|
||||
basic_report_about report, subject_class, report_method, default_days
|
||||
basic_report_about report, subject_class, report_method, report.start_date, report.end_date
|
||||
add_counts(report, subject_class)
|
||||
end
|
||||
|
||||
|
@ -531,8 +531,8 @@ class User < ActiveRecord::Base
|
||||
.limit(3)
|
||||
end
|
||||
|
||||
def self.count_by_signup_date(sinceDaysAgo=30)
|
||||
where('created_at > ?', sinceDaysAgo.days.ago).group('date(created_at)').order('date(created_at)').count
|
||||
def self.count_by_signup_date(start_date, end_date)
|
||||
where('created_at >= ? and created_at < ?', start_date, end_date).group('date(created_at)').order('date(created_at)').count
|
||||
end
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user