Skip to content

Commit 465091e

Browse files
committed
Record "sent_at" even if sending fails
* We still want to show this in the UI Jira-Issue: MAV-6232
1 parent d3b182c commit 465091e

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

app/lib/careplus/automated_report_sender.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ def send_batch!(vaccination_records:, academic_year:, date:)
5555

5656
attach_records!(careplus_report:, vaccination_records:)
5757

58+
record_send_attempt!(careplus_report:)
59+
5860
response =
5961
Careplus::Client.send_csv(
6062
username: team.careplus_username,
@@ -108,8 +110,12 @@ def attach_records!(careplus_report:, vaccination_records:)
108110
)
109111
end
110112

113+
def record_send_attempt!(careplus_report:)
114+
careplus_report.update!(sent_at: Time.current)
115+
end
116+
111117
def mark_as_sent!(careplus_report:)
112-
careplus_report.update!(status: :sent, sent_at: Time.current)
118+
careplus_report.update!(status: :sent)
113119
end
114120

115121
def csv_filename(date:, timestamp:)

spec/lib/careplus/automated_report_sender_spec.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@
131131
)
132132

133133
report = CareplusReport.last
134-
expect(report).to have_attributes(status: "failed", sent_at: nil)
134+
expect(report).to have_attributes(status: "failed")
135+
expect(report.sent_at).to be_present
135136
expect(report.vaccination_records).to contain_exactly(record)
136137
end
137138
end
@@ -153,7 +154,8 @@
153154
expect { call }.to raise_error(Timeout::Error)
154155

155156
report = CareplusReport.last
156-
expect(report).to have_attributes(status: "failed", sent_at: nil)
157+
expect(report).to have_attributes(status: "failed")
158+
expect(report.sent_at).to be_present
157159
expect(report.vaccination_records).to contain_exactly(record)
158160
end
159161
end

0 commit comments

Comments
 (0)