diff options
Diffstat (limited to 'server/src/actions/community_view.rs')
-rw-r--r-- | server/src/actions/community_view.rs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/server/src/actions/community_view.rs b/server/src/actions/community_view.rs index 03d822ab..eafda161 100644 --- a/server/src/actions/community_view.rs +++ b/server/src/actions/community_view.rs @@ -21,6 +21,28 @@ table! { } } +table! { + community_moderator_view (id) { + id -> Int4, + community_id -> Int4, + user_id -> Int4, + published -> Timestamp, + user_name -> Varchar, + community_name -> Varchar, + } +} + +table! { + community_follower_view (id) { + id -> Int4, + community_id -> Int4, + user_id -> Int4, + published -> Timestamp, + user_name -> Varchar, + community_name -> Varchar, + } +} + #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize,QueryableByName,Clone)] #[table_name="community_view"] pub struct CommunityView { @@ -51,3 +73,27 @@ impl CommunityView { } } + +#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize,QueryableByName,Clone)] +#[table_name="community_moderator_view"] +pub struct CommunityModeratorView { + pub id: i32, + pub community_id: i32, + pub user_id: i32, + pub published: chrono::NaiveDateTime, + pub user_name : String, + pub community_name: String, +} + +impl CommunityModeratorView { + pub fn for_community(conn: &PgConnection, from_community_id: i32) -> Result<Vec<Self>, Error> { + use actions::community_view::community_moderator_view::dsl::*; + community_moderator_view.filter(community_id.eq(from_community_id)).load::<Self>(conn) + } + + pub fn for_user(conn: &PgConnection, from_user_id: i32) -> Result<Vec<Self>, Error> { + use actions::community_view::community_moderator_view::dsl::*; + community_moderator_view.filter(user_id.eq(from_user_id)).load::<Self>(conn) + } +} + |