summaryrefslogtreecommitdiffstats
path: root/server/src/db/comment_view.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/db/comment_view.rs')
-rw-r--r--server/src/db/comment_view.rs33
1 files changed, 17 insertions, 16 deletions
diff --git a/server/src/db/comment_view.rs b/server/src/db/comment_view.rs
index a37cdbcd..d1b27a3c 100644
--- a/server/src/db/comment_view.rs
+++ b/server/src/db/comment_view.rs
@@ -1,3 +1,4 @@
+// TODO, remove the cross join here, just join to user directly
use crate::db::{fuzzy_search, limit_and_offset, ListingType, MaybeOptional, SortType};
use diesel::{dsl::*, pg::Pg, result::Error, *};
use serde::{Deserialize, Serialize};
@@ -39,7 +40,7 @@ table! {
}
table! {
- comment_mview (id) {
+ comment_fast_view (id) {
id -> Int4,
creator_id -> Int4,
post_id -> Int4,
@@ -76,7 +77,7 @@ table! {
#[derive(
Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize, QueryableByName, Clone,
)]
-#[table_name = "comment_view"]
+#[table_name = "comment_fast_view"]
pub struct CommentView {
pub id: i32,
pub creator_id: i32,
@@ -112,7 +113,7 @@ pub struct CommentView {
pub struct CommentQueryBuilder<'a> {
conn: &'a PgConnection,
- query: super::comment_view::comment_mview::BoxedQuery<'a, Pg>,
+ query: super::comment_view::comment_fast_view::BoxedQuery<'a, Pg>,
listing_type: ListingType,
sort: &'a SortType,
for_community_id: Option<i32>,
@@ -127,9 +128,9 @@ pub struct CommentQueryBuilder<'a> {
impl<'a> CommentQueryBuilder<'a> {
pub fn create(conn: &'a PgConnection) -> Self {
- use super::comment_view::comment_mview::dsl::*;
+ use super::comment_view::comment_fast_view::dsl::*;
- let query = comment_mview.into_boxed();
+ let query = comment_fast_view.into_boxed();
CommentQueryBuilder {
conn,
@@ -198,7 +199,7 @@ impl<'a> CommentQueryBuilder<'a> {
}
pub fn list(self) -> Result<Vec<CommentView>, Error> {
- use super::comment_view::comment_mview::dsl::*;
+ use super::comment_view::comment_fast_view::dsl::*;
let mut query = self.query;
@@ -270,8 +271,8 @@ impl CommentView {
from_comment_id: i32,
my_user_id: Option<i32>,
) -> Result<Self, Error> {
- use super::comment_view::comment_mview::dsl::*;
- let mut query = comment_mview.into_boxed();
+ use super::comment_view::comment_fast_view::dsl::*;
+ let mut query = comment_fast_view.into_boxed();
// The view lets you pass a null user_id, if you're not logged in
if let Some(my_user_id) = my_user_id {
@@ -290,7 +291,7 @@ impl CommentView {
// The faked schema since diesel doesn't do views
table! {
- reply_view (id) {
+ reply_fast_view (id) {
id -> Int4,
creator_id -> Int4,
post_id -> Int4,
@@ -328,7 +329,7 @@ table! {
#[derive(
Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize, QueryableByName, Clone,
)]
-#[table_name = "reply_view"]
+#[table_name = "reply_fast_view"]
pub struct ReplyView {
pub id: i32,
pub creator_id: i32,
@@ -365,7 +366,7 @@ pub struct ReplyView {
pub struct ReplyQueryBuilder<'a> {
conn: &'a PgConnection,
- query: super::comment_view::reply_view::BoxedQuery<'a, Pg>,
+ query: super::comment_view::reply_fast_view::BoxedQuery<'a, Pg>,
for_user_id: i32,
sort: &'a SortType,
unread_only: bool,
@@ -375,9 +376,9 @@ pub struct ReplyQueryBuilder<'a> {
impl<'a> ReplyQueryBuilder<'a> {
pub fn create(conn: &'a PgConnection, for_user_id: i32) -> Self {
- use super::comment_view::reply_view::dsl::*;
+ use super::comment_view::reply_fast_view::dsl::*;
- let query = reply_view.into_boxed();
+ let query = reply_fast_view.into_boxed();
ReplyQueryBuilder {
conn,
@@ -411,7 +412,7 @@ impl<'a> ReplyQueryBuilder<'a> {
}
pub fn list(self) -> Result<Vec<ReplyView>, Error> {
- use super::comment_view::reply_view::dsl::*;
+ use super::comment_view::reply_fast_view::dsl::*;
let mut query = self.query;
@@ -615,8 +616,8 @@ mod tests {
upvotes: 1,
user_id: Some(inserted_user.id),
my_vote: Some(1),
- subscribed: None,
- saved: None,
+ subscribed: Some(false),
+ saved: Some(false),
ap_id: "http://fake.com".to_string(),
local: true,
community_actor_id: inserted_community.actor_id.to_owned(),