Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions opsqueue/src/common/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,12 +558,12 @@ pub mod db {
/// Returns an error if any batch insert fails.
#[tracing::instrument(skip(chunks, conn))]
pub async fn insert_many_chunks(
chunks: &[Chunk],
chunks: impl IntoIterator<Item = Chunk>,
mut conn: impl WriterConnection,
) -> sqlx::Result<()> {
const ROWS_PER_QUERY: usize = 1000;

let mut iter = chunks.iter().peekable();
let mut iter = chunks.into_iter().peekable();
while iter.peek().is_some() {
let query_chunks = iter.by_ref().take(ROWS_PER_QUERY);

Expand All @@ -573,7 +573,7 @@ pub mod db {
query_builder.push_values(query_chunks, |mut b, chunk| {
b.push_bind(chunk.submission_id)
.push_bind(chunk.chunk_index)
.push_bind(chunk.input_content.clone());
.push_bind(chunk.input_content);
});
let query = query_builder.build();

Expand Down
2 changes: 1 addition & 1 deletion opsqueue/src/common/submission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ pub mod db {
&mut tx,
)
.await?;
super::chunk::db::insert_many_chunks(&chunks, &mut tx).await?;
super::chunk::db::insert_many_chunks(chunks, &mut tx).await?;
Ok(())
}
.boxed()
Expand Down
Loading