From d1c45159b9bb23553768b06ce7ad97ec38e8b845 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sat, 14 Apr 2018 17:47:31 +0200 Subject: feat(db): Add support for stickies in database Adds a 'sticky' column to threads and rewrites the thread index to take sticky markings into account when ordering threads. Stickies are not yet highlighted in any way in the forum overview. --- src/models.rs | 8 ++++++-- src/render.rs | 2 +- src/schema.rs | 8 ++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/models.rs b/src/models.rs index 159a85469aeb..9d3405e1540f 100644 --- a/src/models.rs +++ b/src/models.rs @@ -24,6 +24,7 @@ pub struct Thread { pub posted: DateTime, pub author_name: String, pub author_email: String, + pub sticky: bool, } /// This struct is used as the query type for the thread index view, @@ -33,9 +34,12 @@ pub struct Thread { pub struct ThreadIndex { pub thread_id: i32, pub title: String, - pub author_name: String, - pub posted: DateTime, + pub thread_author: String, + pub created: DateTime, + pub sticky: bool, pub post_id: i32, + pub post_author: String, + pub posted: DateTime, } #[derive(Identifiable, Queryable, Serialize, Associations)] diff --git a/src/render.rs b/src/render.rs index 66b3fe19c867..598d48bce893 100644 --- a/src/render.rs +++ b/src/render.rs @@ -72,7 +72,7 @@ impl Handler for Renderer { id: thread.thread_id, title: escape_html(&thread.title), posted: thread.posted.into(), - author_name: thread.author_name, + author_name: thread.thread_author, }) .collect(); diff --git a/src/schema.rs b/src/schema.rs index 02392c8fc60c..50a55c786825 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -16,6 +16,7 @@ table! { posted -> Timestamptz, author_name -> Varchar, author_email -> Varchar, + sticky -> Bool, } } @@ -24,9 +25,12 @@ table! { thread_index (thread_id){ thread_id -> Integer, title -> Text, - author_name -> Text, - posted -> Timestamptz, + thread_author -> Text, + created -> Timestamptz, + sticky -> Bool, post_id -> Integer, + post_author -> Text, + posted -> Timestamptz, } } -- cgit 1.4.1