bug fixed

This commit is contained in:
병준 박 2022-09-16 10:56:48 +00:00
parent aab4804573
commit d8db1c4d5c
2 changed files with 7 additions and 14 deletions

View File

@ -573,7 +573,7 @@ impl Composition {
Ok(Some(models::from_member_model( Ok(Some(models::from_member_model(
&_m, &_m,
self.select_parent(conn, _m.parent_member_id)?, 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( Ok(Some(models::from_member_model(
&_m, &_m,
self.select_parent(conn, _m.parent_member_id)?, 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( pub fn select_children_count(
&self, &self,
conn: &diesel::PgConnection, conn: &diesel::PgConnection,
parent_member_id: Option<uuid::Uuid>, parent_member_id: uuid::Uuid,
) -> Result<Vec<i64>, Error> { ) -> Result<Vec<i64>, Error> {
use diesel::sql_types::BigInt; use diesel::sql_types::BigInt;
@ -628,13 +628,6 @@ impl Composition {
count_of_children: i64, count_of_children: i64,
} }
let parent_member_id = match parent_member_id {
Some(i) => i,
None => {
return Ok(vec![]);
}
};
let query = format!( let query = format!(
" "
{} {}
@ -709,7 +702,7 @@ impl Composition {
p = Some(models::from_member_model( p = Some(models::from_member_model(
&m, &m,
p, 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( list.push(models::from_member_model(
&_m, &_m,
self.select_parent(conn, _m.parent_member_id)?, self.select_parent(conn, _m.parent_member_id)?,
self.select_children_count(conn, _m.parent_member_id)?, self.select_children_count(conn, _m.id)?,
)); ));
} }

View File

@ -69,7 +69,7 @@ impl From<&compositions::member::models::MemberModel> for bpr::models::member::M
parent_member: d parent_member: d
.parent_member .parent_member
.as_ref() .as_ref()
.map(|v| Box::<bpr::models::member::MemberModel>::from(v)), .map(Box::<bpr::models::member::MemberModel>::from),
child_member_count: d.child_member_count as u64, child_member_count: d.child_member_count as u64,
children_count: d.children_count.iter().map(|v| *v as u64).collect(), children_count: d.children_count.iter().map(|v| *v as u64).collect(),
username: d.username.clone(), username: d.username.clone(),
@ -114,7 +114,7 @@ impl From<&Box<compositions::member::models::MemberModel>>
parent_member: d parent_member: d
.parent_member .parent_member
.as_ref() .as_ref()
.map(|v| Box::<bpr::models::member::MemberModel>::from(v)), .map(Box::<bpr::models::member::MemberModel>::from),
child_member_count: d.child_member_count as u64, child_member_count: d.child_member_count as u64,
children_count: d.children_count.iter().map(|v| *v as u64).collect(), children_count: d.children_count.iter().map(|v| *v as u64).collect(),
username: d.username.clone(), username: d.username.clone(),