X-Git-Url: http://these/git/?a=blobdiff_plain;f=crates%2Fdb_views_moderator%2Fsrc%2Fmod_lock_post_view.rs;h=15ff7855c50ef111e2af6501e133898350deee98;hb=985fe24669d3fdeecc0aa76cc74dd6570cbad5c8;hp=27758446c2b6522333abab2ff85828662aadce8d;hpb=48f187188bce9f5fa1ac8ee09615540ee4df8540;p=lemmy.git diff --git a/crates/db_views_moderator/src/mod_lock_post_view.rs b/crates/db_views_moderator/src/mod_lock_post_view.rs index 27758446..15ff7855 100644 --- a/crates/db_views_moderator/src/mod_lock_post_view.rs +++ b/crates/db_views_moderator/src/mod_lock_post_view.rs @@ -12,17 +12,12 @@ use diesel_async::RunQueryDsl; use lemmy_db_schema::{ newtypes::PersonId, schema::{community, mod_lock_post, person, post}, - source::{ - community::{Community, CommunitySafe}, - moderator::ModLockPost, - person::{Person, PersonSafe}, - post::Post, - }, - traits::{ToSafe, ViewToVec}, + source::{community::Community, moderator::ModLockPost, person::Person, post::Post}, + traits::JoinView, utils::{get_conn, limit_and_offset, DbPool}, }; -type ModLockPostViewTuple = (ModLockPost, Option, Post, CommunitySafe); +type ModLockPostViewTuple = (ModLockPost, Option, Post, Community); impl ModLockPostView { pub async fn list(pool: &DbPool, params: ModlogListParams) -> Result, Error> { @@ -43,9 +38,9 @@ impl ModLockPostView { .inner_join(person_alias_1.on(post::creator_id.eq(person_alias_1.field(person::id)))) .select(( mod_lock_post::all_columns, - Person::safe_columns_tuple().nullable(), + person::all_columns.nullable(), post::all_columns, - Community::safe_columns_tuple(), + community::all_columns, )) .into_boxed(); @@ -70,22 +65,19 @@ impl ModLockPostView { .load::(conn) .await?; - let results = Self::from_tuple_to_vec(res); + let results = res.into_iter().map(Self::from_tuple).collect(); Ok(results) } } -impl ViewToVec for ModLockPostView { - type DbTuple = ModLockPostViewTuple; - fn from_tuple_to_vec(items: Vec) -> Vec { - items - .into_iter() - .map(|a| Self { - mod_lock_post: a.0, - moderator: a.1, - post: a.2, - community: a.3, - }) - .collect::>() +impl JoinView for ModLockPostView { + type JoinTuple = ModLockPostViewTuple; + fn from_tuple(a: Self::JoinTuple) -> Self { + Self { + mod_lock_post: a.0, + moderator: a.1, + post: a.2, + community: a.3, + } } }