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).
This commit is contained in:
parent
cf64826e4e
commit
f10bd20276
6 changed files with 45 additions and 7 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue