Sha256: 5a879e7442683f51703f1e762ea90ea498c7a39217385049f644186298eb468d

Contents?: true

Size: 697 Bytes

Versions: 7

Compression:

Stored size: 697 Bytes

Contents

class DailyEmailReportJob
  def perform(date=nil)

    date ||= 1.day.ago

    #
    # We have to go back two days here intentionally to account for orgs across different time zones
    # We'll re-select the correct orders in the respective jobs
    #
    org_ids = Order.csv_not_imported.after(date-1.day).before(DateTime.now).pluck(:organization_id).uniq
    Organization.where(:id => org_ids).receiving_sales_email.each do |org|
      tickets = DailyTicketReport.new(org, date)
      donations = DailyDonationReport.new(org, date)
      next if tickets.rows.empty? && donations.rows.empty? && tickets.exchange_rows.empty?
      ReportsMailer.daily(tickets, donations).deliver
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
artfully_ose-1.2.0.pre.6 app/models/job/daily_email_report_job.rb
artfully_ose-1.2.0.pre.5 app/models/job/daily_email_report_job.rb
artfully_ose-1.2.0.pre.4 app/models/job/daily_email_report_job.rb
artfully_ose-1.2.0.pre.3 app/models/job/daily_email_report_job.rb
artfully_ose-1.2.0.pre.2 app/models/job/daily_email_report_job.rb
artfully_ose-1.2.0.pre.1 app/models/job/daily_email_report_job.rb
artfully_ose-1.2.0.pre app/models/job/daily_email_report_job.rb