From abefd93be559eb8dcb58c3f5c7fa32ba13e3d0d4 Mon Sep 17 00:00:00 2001 From: philipp Date: Fri, 22 Mar 2024 20:48:04 +0100 Subject: [PATCH 1/2] add db pic, created with sqleton --- db.svg | 494 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 494 insertions(+) create mode 100644 db.svg diff --git a/db.svg b/db.svg new file mode 100644 index 0000000..8a0ac41 --- /dev/null +++ b/db.svg @@ -0,0 +1,494 @@ + + + + + + +undefined + +db.sqlite + + +user + +user + +id* +integer +name +text +pw +text +deleted +boolean +last_access +datetime +dob +text +weight +text +sex +text +dirty_thirty +text +dirty_dozen +text +member_since_date +text +birthdate +text +mail +text +nickname +text +notes +text +phone +text +address +text +family_id +integer +membership_pdf +blob + + + +family + +family + +id* +integer + + + +user->family + + + + + +trip_details + +trip_details + +id* +integer +planned_starting_time +text +max_people +integer +day +text +notes +text +trip_type_id +integer +allow_guests +boolean +always_show +boolean +is_locked +boolean + + + +trip_type + +trip_type + +id* +integer +name +text +desc +text +question +text +icon +text + + + +trip_details->trip_type + + + + + +planned_event + +planned_event + +id* +integer +name +text +planned_amount_cox +integer unsigned +trip_details_id +integer +created_at +text + + + +planned_event->trip_details + + + + + +trip + +trip + +id* +integer +cox_id +integer +trip_details_id +integer +planned_event_id +integer +created_at +text + + + +trip->user + + + + + +trip->trip_details + + + + + +trip->planned_event + + + + + +location + +location + +id* +integer +name +text + + + +boat + +boat + +id* +integer +name +text +amount_seats +integer +location_id +integer +owner +integer +year_built +integer +boatbuilder +text +default_shipmaster_only_steering +boolean +skull +boolean +external +boolean +default_destination +text + + + +boat->user + + + + + +boat->location + + + + + +logbook_type + +logbook_type + +id* +integer +name +text + + + +log + +log + +id* +integer +msg +text +created_at +datetime + + + +boat_damage + +boat_damage + +id* +integer +boat_id +integer +desc +text +user_id_created +integer +created_at +datetime +user_id_fixed +integer +fixed_at +datetime +user_id_verified +integer +verified_at +datetime +lock_boat +boolean + + + +boat_damage->user + + + + + +boat_damage->user + + + + + +boat_damage->user + + + + + +boat_damage->boat + + + + + +user_trip + +user_trip + +user_id +integer +user_note +text +trip_details_id +integer +created_at +text + + + +user_trip->user + + + + + +user_trip->trip_details + + + + + +rower + +rower + +logbook_id +integer +rower_id +integer + + + +rower->user + + + + + +logbook + +logbook + +id* +integer +boat_id +integer +shipmaster +integer +steering_person +integer +shipmaster_only_steering +boolean +departure +datetime +arrival +datetime +destination +text +distance_in_km +integer +comments +text +logtype +integer + + + +rower->logbook + + + + + +logbook->user + + + + + +logbook->user + + + + + +logbook->boat + + + + + +logbook->logbook_type + + + + + +role + +role + +id* +integer +name +text + + + +user_role + +user_role + +user_id +integer +role_id +integer + + + +user_role->user + + + + + +user_role->role + + + + + +boathouse + +boathouse + +id* +integer +boat_id +integer +aisle +text +side +text +level +integer + + + +boathouse->boat + + + + + +notification + +notification + +id* +integer +user_id +integer +message +text +read_at +datetime +created_at +datetime +category +text +link +text + + + +notification->user + + + + + -- 2.45.2 From ef4e6f57d97ebf20239a669a970d7ce2c5524e32 Mon Sep 17 00:00:00 2001 From: philipp Date: Sun, 31 Mar 2024 13:07:40 +0200 Subject: [PATCH 2/2] only show read notifications for last 30 days --- src/model/notification.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/model/notification.rs b/src/model/notification.rs index 3268e6d..2a661cf 100644 --- a/src/model/notification.rs +++ b/src/model/notification.rs @@ -58,7 +58,16 @@ impl Notification { pub async fn for_user(db: &SqlitePool, user: &User) -> Vec { sqlx::query_as!( Self, - "SELECT * FROM notification WHERE user_id = ? ORDER BY created_at DESC", + " +SELECT * FROM notification +WHERE + user_id = ? + AND ( + read_at IS NULL + OR read_at >= datetime('now', '-30 days') + ) +ORDER BY read_at DESC, created_at DESC; + ", user.id ) .fetch_all(db) -- 2.45.2