From 9973913af6b3a0b01638923f8a3df1590d375e48 Mon Sep 17 00:00:00 2001 From: philipp Date: Tue, 28 May 2024 11:26:22 +0200 Subject: [PATCH 1/3] migrated db --- staging-diff.sql | 2 -- 1 file changed, 2 deletions(-) diff --git a/staging-diff.sql b/staging-diff.sql index 4303b65..6fb21fc 100644 --- a/staging-diff.sql +++ b/staging-diff.sql @@ -1,5 +1,3 @@ -update role set name='manage_events' where id=19; - -- test user INSERT INTO user(name) VALUES('Marie'); INSERT INTO "user_role" (user_id, role_id) VALUES((SELECT id from user where name = 'Marie'),(SELECT id FROM role where name = 'Donau Linz')); -- 2.45.2 From 562c32939d6c9090ade9b2c3eb0bb26bec9d6b9d Mon Sep 17 00:00:00 2001 From: philipp Date: Thu, 30 May 2024 10:39:55 +0200 Subject: [PATCH 2/3] better phrasing of text --- src/model/event.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/model/event.rs b/src/model/event.rs index c0c8349..cc7664c 100644 --- a/src/model/event.rs +++ b/src/model/event.rs @@ -282,16 +282,17 @@ WHERE trip_details.id=? let rower = Registration::all_rower(db, self.trip_details_id).await; for user in rower { if let Some(user) = User::find_by_name(db, &user.name).await { - let notes = match update.notes { - Some(n) if !n.is_empty() => n, - _ => ".", + let notes = if let Some(notes) = update.notes { + format!("Grund der Absage: {notes}") + } else { + String::from("") }; Notification::create( db, &user, &format!( - "Die Ausfahrt {} am {} um {} wurde abgesagt{}", + "Die Ausfahrt {} am {} um {} wurde abgesagt. {}", self.name, self.day, self.planned_starting_time, notes ), "Absage Ausfahrt", -- 2.45.2 From 1bd643f6f471a5bb30bb42bb5e0f61489daf7bec Mon Sep 17 00:00:00 2001 From: philipp Date: Thu, 30 May 2024 11:11:08 +0200 Subject: [PATCH 3/3] try --- src/model/notification.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/model/notification.rs b/src/model/notification.rs index 9bb242e..d3bcd81 100644 --- a/src/model/notification.rs +++ b/src/model/notification.rs @@ -135,12 +135,22 @@ ORDER BY read_at DESC, created_at DESC; .await .unwrap(); + println!("in mark_read"); + if let Some(action) = self.action_after_reading.as_ref() { + println!("{action:#?}"); // User read notification about cancelled trip/event let re = Regex::new(r"^remove_user_trip_with_trip_details_id:(\d+)$").unwrap(); if let Some(caps) = re.captures(action) { + println!("in 2nd if"); if let Some(matched) = caps.get(1) { + println!("in 3rd if"); if let Ok(number) = matched.as_str().parse::() { + println!("number: {number}"); + println!( + "DELETE FROM user_trip WHERE user_id = {} AND trip_details_id = {}", + self.user_id, number + ); let _ = sqlx::query!( "DELETE FROM user_trip WHERE user_id = ? AND trip_details_id = ?", self.user_id, -- 2.45.2