Bläddra i källkod

Sort by idx column when displaying results

Mark Rousskov 5 år sedan
förälder
incheckning
db1f714c1c
2 ändrade filer med 3 tillägg och 2 borttagningar
  1. 1 0
      src/db.rs
  2. 2 2
      src/db/notifications.rs

+ 1 - 0
src/db.rs

@@ -69,4 +69,5 @@ CREATE TABLE users (
 ",
     "ALTER TABLE notifications ADD COLUMN short_description TEXT;",
     "ALTER TABLE notifications ADD COLUMN team_name TEXT;",
+    "ALTER TABLE notifications ADD COLUMN idx INTEGER;",
 ];

+ 2 - 2
src/db/notifications.rs

@@ -56,11 +56,11 @@ pub async fn get_notifications(
     let notifications = db
         .query(
             "
-        select username, origin_url, origin_html, time, short_description
+        select username, origin_url, origin_html, time, short_description, idx
         from notifications
         join users on notifications.user_id = users.user_id
         where username = $1
-        order by time desc;",
+        order by notifications.idx desc, notifications.time desc;",
             &[&username],
         )
         .await