about summary refs log tree commit diff
path: root/src/db.rs
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@gmail.com>2018-04-14T15·15+0200
committerVincent Ambo <tazjin@gmail.com>2018-04-14T15·15+0200
commitf10bd20276dc1271b3a17197adf53a014c5979b1 (patch)
tree41851be75309e6395dc1f2d6f11aad4255313833 /src/db.rs
parentcf64826e4eda1ee7839a9a3e9b114564b3cced92 (diff)
feat(db): Add view for ordering thread index by most recent post
This implements the classic thread ordering expected by most forum
users (i.e. the thread with the most recent post is at the top).
Diffstat (limited to 'src/db.rs')
-rw-r--r--src/db.rs9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/db.rs b/src/db.rs
index c26597293706..5a66fbb0fc74 100644
--- a/src/db.rs
+++ b/src/db.rs
@@ -36,19 +36,18 @@ impl Actor for DbExecutor {
 pub struct ListThreads;
 
 impl Message for ListThreads {
-    type Result = Result<Vec<Thread>>;
+    type Result = Result<Vec<ThreadIndex>>;
 }
 
 impl Handler<ListThreads> for DbExecutor {
     type Result = <ListThreads as Message>::Result;
 
     fn handle(&mut self, _: ListThreads, _: &mut Self::Context) -> Self::Result {
-        use schema::threads::dsl::*;
+        use schema::thread_index::dsl::*;
 
         let conn = self.0.get()?;
-        let results = threads
-            .order(posted.desc())
-            .load::<Thread>(&conn)?;
+        let results = thread_index
+            .load::<ThreadIndex>(&conn)?;
         Ok(results)
     }
 }