app/services/reports/failed_emails_report.rb
def find_failures(record, reference_code, email_type)
        reference = [email_type, reference_code].join(';').freeze

        if record.sent_at.nil?
          failures << report_line(record, reference, 'error')
          return
        end

        # Ignore following failures when sending the report, as these are very
        # frequently user typos, and nothing we can fix on our side.
        return if report_type == :daily_tasks && email_type == USER_EMAIL_TYPE

        status = EmailSubmissionsAudit.unscoped.order(completed_at: :desc).find_by(
          reference: reference,
        )&.status || 'callback-missing'

        return if status == SUCCESSFUL_STATUS_CALLBACK

        failures << report_line(record, reference, status)
      end
# This class method is used in the back-office
This class method is used in the back-office
This class method is used in the back - office
def find_failures(record, reference_code, email_type)
        reference = [email_type, reference_code].join(';').freeze
        if record.sent_at.nil?
          failures << report_line(record, reference, 'error')
          return
        end
        return if report_type == :daily_tasks && email_type == USER_EMAIL_TYPE
        status = EmailSubmissionsAudit.unscoped.order(completed_at: :desc).find_by(
          reference: reference,
        )&.status || 'callback-missing'
        return if status == SUCCESSFUL_STATUS_CALLBACK
        failures << report_line(record, reference, status)
      end
def find_failures ( record , reference_code , email_type ) reference = [ email_type , reference_code ] . join ( ';' ) . freeze if record . sent_at . nil? failures << report_line ( record , reference , 'error' ) return end return if report_type == :daily_tasks && email_type == USER_EMAIL_TYPE status = EmailSubmissionsAudit . unscoped . order ( completed_at : :desc ) . find_by ( reference : reference , ) &. status || 'callback-missing' return if status == SUCCESSFUL_STATUS_CALLBACK failures << report_line ( record , reference , status ) end
This class method is used in the back-office
This class method is used in the back - office
# Ignore following failures when sending the report, as these are very # frequently user typos, and nothing we can fix on our side.
record
reference_code
email_type