Compare commits

...

3 Commits

Author SHA1 Message Date
6ba97e2631 Merge pull request 'dont-notify-cancelled-trips' (#712) from dont-notify-cancelled-trips into staging
All checks were successful
CI/CD Pipeline / test (push) Successful in 10m58s
CI/CD Pipeline / deploy-staging (push) Successful in 8m25s
CI/CD Pipeline / deploy-main (push) Has been skipped
Reviewed-on: #712
2024-08-27 09:25:04 +02:00
a52ee97a80 don't notify cancelled trips
Some checks failed
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled
2024-08-27 09:24:21 +02:00
0b46cbf8db Merge pull request 'allow retroactively adding logbook entrie' (#711) from allow-retro-logbookentry into main
All checks were successful
CI/CD Pipeline / test (push) Successful in 10m52s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Successful in 8m12s
Reviewed-on: #711
2024-08-23 12:26:45 +02:00
2 changed files with 29 additions and 18 deletions

View File

@ -77,8 +77,16 @@ impl Trip {
.await;
if same_starting_datetime.len() > 1 {
for notify in same_starting_datetime {
if notify.id != trip_details.id {
// notify everyone except oneself
// don't notify oneself
if notify.id == trip_details.id {
continue;
}
// don't notify people who have cancelled their trip
if notify.cancelled(db) {
continue;
}
if let Some(trip) = Trip::find_by_trip_details(db, notify.id).await {
let user = User::find_by_id(db, trip.cox_id as i32).await.unwrap();
Notification::create(
@ -97,7 +105,6 @@ impl Trip {
}
}
}
}
pub async fn find_by_trip_details(db: &SqlitePool, tripdetails_id: i64) -> Option<Self> {
sqlx::query_as!(

View File

@ -77,6 +77,10 @@ WHERE day = ? AND planned_starting_time = ?
.await.unwrap()
}
pub fn cancelled(&self, db: &SqlitePool) -> bool {
self.max_people == 0
}
/// This function is called when a person registers to a trip or when the cox changes the
/// amount of free places.
pub async fn check_free_spaces(&self, db: &SqlitePool) {
@ -85,7 +89,7 @@ WHERE day = ? AND planned_starting_time = ?
return;
}
if self.max_people == 0 {
if self.cancelled(db) {
// Cox cancelled event, thus it's probably bad weather. Don't bother with sending
// notifications
return;