Show messages when imports succeed.

This commit is contained in:
jude
2023-09-24 14:14:21 +01:00
parent 541633270c
commit 8ddff698e5
3 changed files with 36 additions and 12 deletions

View File

@ -136,6 +136,7 @@ pub(crate) async fn import_reminders(
match base64::decode(&body.body) {
Ok(body) => {
let mut reader = csv::Reader::from_reader(body.as_slice());
let mut count = 0;
for result in reader.deserialize::<ReminderCsv>() {
match result {
@ -184,6 +185,8 @@ pub(crate) async fn import_reminders(
reminder,
)
.await?;
count += 1;
}
Err(_) => {
@ -204,7 +207,9 @@ pub(crate) async fn import_reminders(
}
match transaction.commit().await {
Ok(_) => Ok(json!({})),
Ok(_) => Ok(json!({
"message": format!("Imported {} reminders", count)
})),
Err(e) => {
warn!("Failed to commit transaction: {:?}", e);