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
|
|
@ -26,6 +26,18 @@ pub struct Thread {
|
|||
pub author_email: String,
|
||||
}
|
||||
|
||||
/// This struct is used as the query type for the thread index view,
|
||||
/// which lists the index of threads ordered by the last post in each
|
||||
/// thread.
|
||||
#[derive(Queryable, Serialize)]
|
||||
pub struct ThreadIndex {
|
||||
pub thread_id: i32,
|
||||
pub title: String,
|
||||
pub author_name: String,
|
||||
pub posted: DateTime<Utc>,
|
||||
pub post_id: i32,
|
||||
}
|
||||
|
||||
#[derive(Identifiable, Queryable, Serialize, Associations)]
|
||||
#[belongs_to(Thread)]
|
||||
pub struct Post {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue