forked from didirus/AstralRinth
Batch inserts [MOD-555] (#726)
* Batch a bunch of inserts, but still more to do * Insert many for clickhouse (+ tests) * Batch the remaining ones except those requiring deduplication * Risky dedups * Bit o cleanup and formatting * cargo sqlx prepare * Add test around batch editing project categories * Add struct to satisfy clippy * Fix silly mistake that was caught by the tests! * Leave room for growth in dummy_data
This commit is contained in:
@@ -90,22 +90,20 @@ impl ThreadBuilder {
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
|
||||
for member in &self.members {
|
||||
sqlx::query!(
|
||||
"
|
||||
INSERT INTO threads_members (
|
||||
thread_id, user_id
|
||||
)
|
||||
VALUES (
|
||||
$1, $2
|
||||
)
|
||||
",
|
||||
thread_id as ThreadId,
|
||||
*member as UserId,
|
||||
let (thread_ids, members): (Vec<_>, Vec<_>) =
|
||||
self.members.iter().map(|m| (thread_id.0, m.0)).unzip();
|
||||
sqlx::query!(
|
||||
"
|
||||
INSERT INTO threads_members (
|
||||
thread_id, user_id
|
||||
)
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
}
|
||||
SELECT * FROM UNNEST ($1::int8[], $2::int8[])
|
||||
",
|
||||
&thread_ids[..],
|
||||
&members[..],
|
||||
)
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
|
||||
Ok(thread_id)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user