Rewrite multi loader query use
This commit is contained in:
parent
1d0ab456b9
commit
9c1b13bfb7
@ -236,7 +236,7 @@ impl FindProducts {
|
||||
self,
|
||||
pool: &mut sqlx::Transaction<'_, sqlx::Postgres>,
|
||||
) -> Result<Vec<Product>> {
|
||||
db_utils::MultiLoad::new(
|
||||
let mut loader = db_utils::MultiLoad::new(
|
||||
pool,
|
||||
r#"
|
||||
SELECT id,
|
||||
@ -248,16 +248,17 @@ WHERE
|
||||
"#,
|
||||
"products.id =",
|
||||
)
|
||||
.with_size(200)
|
||||
.load(
|
||||
self.product_ids.len(),
|
||||
self.product_ids.into_iter().map(|id| *id),
|
||||
|e| {
|
||||
tracing::error!("{e:?}");
|
||||
Error::FindProducts
|
||||
},
|
||||
)
|
||||
.await
|
||||
.with_size(200);
|
||||
loader
|
||||
.load(
|
||||
self.product_ids.len(),
|
||||
self.product_ids.into_iter().map(|id| *id),
|
||||
|e| {
|
||||
tracing::error!("{e:?}");
|
||||
Error::FindProducts
|
||||
},
|
||||
)
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
@ -372,10 +373,7 @@ mod tests {
|
||||
Product {
|
||||
id: original.id,
|
||||
name: ProductName::new("a9s0dja0sjd0jas09dj"),
|
||||
short_description: ProductShortDesc::new("ajs9d8ua9sdu9ahsd98has"),
|
||||
long_description: ProductLongDesc::new("hja89sdy9yha9sdy98ayusd9hya9sy8dh"),
|
||||
category: None,
|
||||
price: Price::from_u32(823794),
|
||||
deliver_days_flag: Day::Tuesday | Day::Saturday,
|
||||
}
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user