Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions app/jobs/reports/protocols_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@ class ProtocolsReport < BaseReport

attr_accessor :report_date

def initialize(report_date = nil, *args, **rest)
@report_date = report_date
super(*args, **rest)
end

def perform(report_date)
def perform(date = Time.zone.yesterday.end_of_day)
return unless IdentityConfig.store.s3_reports_enabled

self.report_date = report_date
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd remove the initializer just in case and use the attr_accessor for specs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the ReportMailerPreview needs the date added via initializer, since it bypasses the perform method :(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could do

    report = Reports::ProtocolsReport.new.tap { |r| r.report_date = date }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated in 42711be

@report_date = date
message = "Report: #{REPORT_NAME} #{report_date}"
subject = "Weekly Protocols Report - #{report_date}"

Expand Down
2 changes: 1 addition & 1 deletion spec/mailers/previews/report_mailer_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def monthly_key_metrics_report

def protocols_report
date = Time.zone.yesterday
report = Reports::ProtocolsReport.new(date)
report = Reports::ProtocolsReport.new.tap { |r| r.report_date = date }

stub_cloudwatch_client(report.send(:report))

Expand Down