diff --git a/src/compositions/member/composition.rs b/src/compositions/member/composition.rs index 8dd7e18..5017445 100644 --- a/src/compositions/member/composition.rs +++ b/src/compositions/member/composition.rs @@ -573,7 +573,7 @@ impl Composition { Ok(Some(models::from_member_model( &_m, self.select_parent(conn, _m.parent_member_id)?, - self.select_children_count(conn, _m.parent_member_id)?, + self.select_children_count(conn, _m.id)?, ))) } @@ -610,7 +610,7 @@ impl Composition { Ok(Some(models::from_member_model( &_m, self.select_parent(conn, _m.parent_member_id)?, - self.select_children_count(conn, _m.parent_member_id)?, + self.select_children_count(conn, _m.id)?, ))) } @@ -618,7 +618,7 @@ impl Composition { pub fn select_children_count( &self, conn: &diesel::PgConnection, - parent_member_id: Option, + parent_member_id: uuid::Uuid, ) -> Result, Error> { use diesel::sql_types::BigInt; @@ -628,13 +628,6 @@ impl Composition { count_of_children: i64, } - let parent_member_id = match parent_member_id { - Some(i) => i, - None => { - return Ok(vec![]); - } - }; - let query = format!( " {} @@ -709,7 +702,7 @@ impl Composition { p = Some(models::from_member_model( &m, p, - self.select_children_count(conn, m.parent_member_id)?, + self.select_children_count(conn, m.id)?, )); } @@ -1004,7 +997,7 @@ impl Composition { list.push(models::from_member_model( &_m, self.select_parent(conn, _m.parent_member_id)?, - self.select_children_count(conn, _m.parent_member_id)?, + self.select_children_count(conn, _m.id)?, )); } diff --git a/src/services/member/models.rs b/src/services/member/models.rs index 15017bd..c1b5e91 100644 --- a/src/services/member/models.rs +++ b/src/services/member/models.rs @@ -69,7 +69,7 @@ impl From<&compositions::member::models::MemberModel> for bpr::models::member::M parent_member: d .parent_member .as_ref() - .map(|v| Box::::from(v)), + .map(Box::::from), child_member_count: d.child_member_count as u64, children_count: d.children_count.iter().map(|v| *v as u64).collect(), username: d.username.clone(), @@ -114,7 +114,7 @@ impl From<&Box> parent_member: d .parent_member .as_ref() - .map(|v| Box::::from(v)), + .map(Box::::from), child_member_count: d.child_member_count as u64, children_count: d.children_count.iter().map(|v| *v as u64).collect(), username: d.username.clone(),