diff options
author | Vincent Ambo <tazjin@gmail.com> | 2018-04-14T15·47+0200 |
---|---|---|
committer | Vincent Ambo <tazjin@gmail.com> | 2018-04-14T15·47+0200 |
commit | d1c45159b9bb23553768b06ce7ad97ec38e8b845 (patch) | |
tree | f6dae457fddcb75bb6a3c65eec699868beb3b89f /src | |
parent | c136d34e798f399c515b31d90fd1194b02005c96 (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/models.rs | 8 | ||||
-rw-r--r-- | src/render.rs | 2 | ||||
-rw-r--r-- | src/schema.rs | 8 |
3 files changed, 13 insertions, 5 deletions
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<Utc>, 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<Utc>, + pub thread_author: String, + pub created: DateTime<Utc>, + pub sticky: bool, pub post_id: i32, + pub post_author: String, + pub posted: DateTime<Utc>, } #[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<IndexPage> 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, } } |