+++ /dev/null
-alter table comment enable trigger refresh_comment;
-alter table user_ enable trigger refresh_user;
-alter table post enable trigger refresh_post;
-alter table community enable trigger refresh_community;
-alter table private_message enable trigger refresh_private_message;
-alter table post_like enable trigger refresh_post_like;
-alter table community_follower enable trigger refresh_community_follower;
-alter table community_user_ban enable trigger refresh_community_user_ban;
-alter table comment_like enable trigger refresh_comment_like;
+++ /dev/null
-alter table comment disable trigger refresh_comment;
-alter table user_ disable trigger refresh_user;
-alter table post disable trigger refresh_post;
-alter table community disable trigger refresh_community;
-alter table private_message disable trigger refresh_private_message;
-alter table post_like disable trigger refresh_post_like;
-alter table community_follower disable trigger refresh_community_follower;
-alter table community_user_ban disable trigger refresh_community_user_ban;
-alter table comment_like disable trigger refresh_comment_like;
}
}
+table! {
+ comment_mview (id) {
+ id -> Int4,
+ creator_id -> Int4,
+ post_id -> Int4,
+ parent_id -> Nullable<Int4>,
+ content -> Text,
+ removed -> Bool,
+ read -> Bool,
+ published -> Timestamp,
+ updated -> Nullable<Timestamp>,
+ deleted -> Bool,
+ ap_id -> Text,
+ local -> Bool,
+ community_id -> Int4,
+ community_actor_id -> Text,
+ community_local -> Bool,
+ community_name -> Varchar,
+ banned -> Bool,
+ banned_from_community -> Bool,
+ creator_actor_id -> Text,
+ creator_local -> Bool,
+ creator_name -> Varchar,
+ creator_avatar -> Nullable<Text>,
+ score -> BigInt,
+ upvotes -> BigInt,
+ downvotes -> BigInt,
+ hot_rank -> Int4,
+ user_id -> Nullable<Int4>,
+ my_vote -> Nullable<Int4>,
+ subscribed -> Nullable<Bool>,
+ saved -> Nullable<Bool>,
+ }
+}
+
#[derive(
Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize, QueryableByName, Clone,
)]
pub struct CommentQueryBuilder<'a> {
conn: &'a PgConnection,
- query: super::comment_view::comment_view::BoxedQuery<'a, Pg>,
+ query: super::comment_view::comment_mview::BoxedQuery<'a, Pg>,
listing_type: ListingType,
sort: &'a SortType,
for_community_id: Option<i32>,
impl<'a> CommentQueryBuilder<'a> {
pub fn create(conn: &'a PgConnection) -> Self {
- use super::comment_view::comment_view::dsl::*;
+ use super::comment_view::comment_mview::dsl::*;
- let query = comment_view.into_boxed();
+ let query = comment_mview.into_boxed();
CommentQueryBuilder {
conn,
}
pub fn list(self) -> Result<Vec<CommentView>, Error> {
- use super::comment_view::comment_view::dsl::*;
+ use super::comment_view::comment_mview::dsl::*;
let mut query = self.query;
from_comment_id: i32,
my_user_id: Option<i32>,
) -> Result<Self, Error> {
- use super::comment_view::comment_view::dsl::*;
- let mut query = comment_view.into_boxed();
+ use super::comment_view::comment_mview::dsl::*;
+ let mut query = comment_mview.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 {
-use super::community_view::community_view::BoxedQuery;
+use super::community_view::community_mview::BoxedQuery;
use crate::db::{fuzzy_search, limit_and_offset, MaybeOptional, SortType};
use diesel::{pg::Pg, result::Error, *};
use serde::{Deserialize, Serialize};
}
}
+table! {
+ community_mview (id) {
+ id -> Int4,
+ name -> Varchar,
+ title -> Varchar,
+ description -> Nullable<Text>,
+ category_id -> Int4,
+ creator_id -> Int4,
+ removed -> Bool,
+ published -> Timestamp,
+ updated -> Nullable<Timestamp>,
+ deleted -> Bool,
+ nsfw -> Bool,
+ actor_id -> Text,
+ local -> Bool,
+ last_refreshed_at -> Timestamp,
+ creator_actor_id -> Text,
+ creator_local -> Bool,
+ creator_name -> Varchar,
+ creator_avatar -> Nullable<Text>,
+ category_name -> Varchar,
+ number_of_subscribers -> BigInt,
+ number_of_posts -> BigInt,
+ number_of_comments -> BigInt,
+ hot_rank -> Int4,
+ user_id -> Nullable<Int4>,
+ subscribed -> Nullable<Bool>,
+ }
+}
+
table! {
community_moderator_view (id) {
id -> Int4,
impl<'a> CommunityQueryBuilder<'a> {
pub fn create(conn: &'a PgConnection) -> Self {
- use super::community_view::community_view::dsl::*;
+ use super::community_view::community_mview::dsl::*;
- let query = community_view.into_boxed();
+ let query = community_mview.into_boxed();
CommunityQueryBuilder {
conn,
}
pub fn list(self) -> Result<Vec<CommunityView>, Error> {
- use super::community_view::community_view::dsl::*;
+ use super::community_view::community_mview::dsl::*;
let mut query = self.query;
from_community_id: i32,
from_user_id: Option<i32>,
) -> Result<Self, Error> {
- use super::community_view::community_view::dsl::*;
+ use super::community_view::community_mview::dsl::*;
- let mut query = community_view.into_boxed();
+ let mut query = community_mview.into_boxed();
query = query.filter(id.eq(from_community_id));
-use super::post_view::post_view::BoxedQuery;
+use super::post_view::post_mview::BoxedQuery;
use crate::db::{fuzzy_search, limit_and_offset, ListingType, MaybeOptional, SortType};
use diesel::{dsl::*, pg::Pg, result::Error, *};
use serde::{Deserialize, Serialize};
}
}
+table! {
+ post_mview (id) {
+ id -> Int4,
+ name -> Varchar,
+ url -> Nullable<Text>,
+ body -> Nullable<Text>,
+ creator_id -> Int4,
+ community_id -> Int4,
+ removed -> Bool,
+ locked -> Bool,
+ published -> Timestamp,
+ updated -> Nullable<Timestamp>,
+ deleted -> Bool,
+ nsfw -> Bool,
+ stickied -> Bool,
+ embed_title -> Nullable<Text>,
+ embed_description -> Nullable<Text>,
+ embed_html -> Nullable<Text>,
+ thumbnail_url -> Nullable<Text>,
+ ap_id -> Text,
+ local -> Bool,
+ banned -> Bool,
+ banned_from_community -> Bool,
+ creator_actor_id -> Text,
+ creator_local -> Bool,
+ creator_name -> Varchar,
+ creator_avatar -> Nullable<Text>,
+ community_actor_id -> Text,
+ community_local -> Bool,
+ community_name -> Varchar,
+ community_removed -> Bool,
+ community_deleted -> Bool,
+ community_nsfw -> Bool,
+ number_of_comments -> BigInt,
+ score -> BigInt,
+ upvotes -> BigInt,
+ downvotes -> BigInt,
+ hot_rank -> Int4,
+ newest_activity_time -> Timestamp,
+ user_id -> Nullable<Int4>,
+ my_vote -> Nullable<Int4>,
+ subscribed -> Nullable<Bool>,
+ read -> Nullable<Bool>,
+ saved -> Nullable<Bool>,
+ }
+}
+
#[derive(
Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize, QueryableByName, Clone,
)]
impl<'a> PostQueryBuilder<'a> {
pub fn create(conn: &'a PgConnection) -> Self {
- use super::post_view::post_view::dsl::*;
+ use super::post_view::post_mview::dsl::*;
- let query = post_view.into_boxed();
+ let query = post_mview.into_boxed();
PostQueryBuilder {
conn,
}
pub fn list(self) -> Result<Vec<PostView>, Error> {
- use super::post_view::post_view::dsl::*;
+ use super::post_view::post_mview::dsl::*;
let mut query = self.query;
from_post_id: i32,
my_user_id: Option<i32>,
) -> Result<Self, Error> {
- use super::post_view::post_view::dsl::*;
+ use super::post_view::post_mview::dsl::*;
use diesel::prelude::*;
- let mut query = post_view.into_boxed();
+ let mut query = post_mview.into_boxed();
query = query.filter(id.eq(from_post_id));
}
}
+table! {
+ private_message_mview (id) {
+ id -> Int4,
+ creator_id -> Int4,
+ recipient_id -> Int4,
+ content -> Text,
+ deleted -> Bool,
+ read -> Bool,
+ published -> Timestamp,
+ updated -> Nullable<Timestamp>,
+ ap_id -> Text,
+ local -> Bool,
+ creator_name -> Varchar,
+ creator_avatar -> Nullable<Text>,
+ creator_actor_id -> Text,
+ creator_local -> Bool,
+ recipient_name -> Varchar,
+ recipient_avatar -> Nullable<Text>,
+ recipient_actor_id -> Text,
+ recipient_local -> Bool,
+ }
+}
+
#[derive(
Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize, QueryableByName, Clone,
)]
pub struct PrivateMessageQueryBuilder<'a> {
conn: &'a PgConnection,
- query: super::private_message_view::private_message_view::BoxedQuery<'a, Pg>,
+ query: super::private_message_view::private_message_mview::BoxedQuery<'a, Pg>,
for_recipient_id: i32,
unread_only: bool,
page: Option<i64>,
impl<'a> PrivateMessageQueryBuilder<'a> {
pub fn create(conn: &'a PgConnection, for_recipient_id: i32) -> Self {
- use super::private_message_view::private_message_view::dsl::*;
+ use super::private_message_view::private_message_mview::dsl::*;
- let query = private_message_view.into_boxed();
+ let query = private_message_mview.into_boxed();
PrivateMessageQueryBuilder {
conn,
}
pub fn list(self) -> Result<Vec<PrivateMessageView>, Error> {
- use super::private_message_view::private_message_view::dsl::*;
+ use super::private_message_view::private_message_mview::dsl::*;
let mut query = self.query.filter(deleted.eq(false));
}
}
+table! {
+ user_mention_mview (id) {
+ id -> Int4,
+ user_mention_id -> Int4,
+ creator_id -> Int4,
+ creator_actor_id -> Text,
+ creator_local -> Bool,
+ post_id -> Int4,
+ parent_id -> Nullable<Int4>,
+ content -> Text,
+ removed -> Bool,
+ read -> Bool,
+ published -> Timestamp,
+ updated -> Nullable<Timestamp>,
+ deleted -> Bool,
+ community_id -> Int4,
+ community_actor_id -> Text,
+ community_local -> Bool,
+ community_name -> Varchar,
+ banned -> Bool,
+ banned_from_community -> Bool,
+ creator_name -> Varchar,
+ creator_avatar -> Nullable<Text>,
+ score -> BigInt,
+ upvotes -> BigInt,
+ downvotes -> BigInt,
+ hot_rank -> Int4,
+ user_id -> Nullable<Int4>,
+ my_vote -> Nullable<Int4>,
+ saved -> Nullable<Bool>,
+ recipient_id -> Int4,
+ recipient_actor_id -> Text,
+ recipient_local -> Bool,
+ }
+}
+
#[derive(
Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize, QueryableByName, Clone,
)]
pub struct UserMentionQueryBuilder<'a> {
conn: &'a PgConnection,
- query: super::user_mention_view::user_mention_view::BoxedQuery<'a, Pg>,
+ query: super::user_mention_view::user_mention_mview::BoxedQuery<'a, Pg>,
for_user_id: i32,
sort: &'a SortType,
unread_only: bool,
impl<'a> UserMentionQueryBuilder<'a> {
pub fn create(conn: &'a PgConnection, for_user_id: i32) -> Self {
- use super::user_mention_view::user_mention_view::dsl::*;
+ use super::user_mention_view::user_mention_mview::dsl::*;
- let query = user_mention_view.into_boxed();
+ let query = user_mention_mview.into_boxed();
UserMentionQueryBuilder {
conn,
}
pub fn list(self) -> Result<Vec<UserMentionView>, Error> {
- use super::user_mention_view::user_mention_view::dsl::*;
+ use super::user_mention_view::user_mention_mview::dsl::*;
let mut query = self.query;
-use super::user_view::user_view::BoxedQuery;
+use super::user_view::user_mview::BoxedQuery;
use crate::db::{fuzzy_search, limit_and_offset, MaybeOptional, SortType};
use diesel::{dsl::*, pg::Pg, result::Error, *};
use serde::{Deserialize, Serialize};
}
}
+table! {
+ user_mview (id) {
+ id -> Int4,
+ actor_id -> Text,
+ name -> Varchar,
+ avatar -> Nullable<Text>,
+ email -> Nullable<Text>,
+ matrix_user_id -> Nullable<Text>,
+ bio -> Nullable<Text>,
+ local -> Bool,
+ admin -> Bool,
+ banned -> Bool,
+ show_avatars -> Bool,
+ send_notifications_to_email -> Bool,
+ published -> Timestamp,
+ number_of_posts -> BigInt,
+ post_score -> BigInt,
+ number_of_comments -> BigInt,
+ comment_score -> BigInt,
+ }
+}
+
#[derive(
Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize, QueryableByName, Clone,
)]
impl<'a> UserQueryBuilder<'a> {
pub fn create(conn: &'a PgConnection) -> Self {
- use super::user_view::user_view::dsl::*;
+ use super::user_view::user_mview::dsl::*;
- let query = user_view.into_boxed();
+ let query = user_mview.into_boxed();
UserQueryBuilder {
conn,
}
pub fn search_term<T: MaybeOptional<String>>(mut self, search_term: T) -> Self {
- use super::user_view::user_view::dsl::*;
+ use super::user_view::user_mview::dsl::*;
if let Some(search_term) = search_term.get_optional() {
self.query = self.query.filter(name.ilike(fuzzy_search(&search_term)));
}
}
pub fn list(self) -> Result<Vec<UserView>, Error> {
- use super::user_view::user_view::dsl::*;
+ use super::user_view::user_mview::dsl::*;
let mut query = self.query;
impl UserView {
pub fn read(conn: &PgConnection, from_user_id: i32) -> Result<Self, Error> {
- use super::user_view::user_view::dsl::*;
- user_view.find(from_user_id).first::<Self>(conn)
+ use super::user_view::user_mview::dsl::*;
+ user_mview.find(from_user_id).first::<Self>(conn)
}
pub fn admins(conn: &PgConnection) -> Result<Vec<Self>, Error> {
- use super::user_view::user_view::dsl::*;
- user_view.filter(admin.eq(true)).load::<Self>(conn)
+ use super::user_view::user_mview::dsl::*;
+ user_mview.filter(admin.eq(true)).load::<Self>(conn)
}
pub fn banned(conn: &PgConnection) -> Result<Vec<Self>, Error> {
- use super::user_view::user_view::dsl::*;
- user_view.filter(banned.eq(true)).load::<Self>(conn)
+ use super::user_view::user_mview::dsl::*;
+ user_mview.filter(banned.eq(true)).load::<Self>(conn)
}
}