Skip to content

Commit 6e20037

Browse files
committed
sentry - db - campaign - ufs campaigns fix
bug with deposit assets
1 parent 70de853 commit 6e20037

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

sentry/src/db/campaign.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,22 @@ pub async fn units_for_slot_get_campaigns(
234234
vec![Box::new(active_to_ge), Box::new(creator)];
235235

236236
// Deposit assets
237-
match deposit_assets {
237+
match deposit_assets.cloned() {
238238
Some(assets) if !assets.is_empty() => {
239-
let assets_vec = assets.iter().copied().collect::<Vec<_>>();
239+
// we start from $3 parameter
240+
let start_index = params.len() + 1;
240241

241-
where_clauses.push("channels.token IN ($3)".into());
242-
params.push(Box::new(assets_vec))
242+
let in_clause = assets.into_iter().enumerate().fold(
243+
vec![],
244+
|mut in_clause, (asset_index, asset)| {
245+
in_clause.push(format!("${}", start_index + asset_index));
246+
params.push(Box::new(asset));
247+
248+
in_clause
249+
},
250+
);
251+
252+
where_clauses.push(format!("channels.token IN ({})", in_clause.join(",")));
243253
}
244254
_ => {}
245255
};

0 commit comments

Comments
 (0)