about summary refs log tree commit diff
path: root/src/models.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/models.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/models.rs')
-rw-r--r--src/models.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/models.rs b/src/models.rs
index 29d196b9a998..159a85469aeb 100644
--- a/src/models.rs
+++ b/src/models.rs
@@ -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 {