Skip to content

Commit a7e3ae6

Browse files
committed
We always save the batch first now, so we don't need to upsert
1 parent f7a1a7b commit a7e3ae6

File tree

1 file changed

+1
-24
lines changed

1 file changed

+1
-24
lines changed

app/models/solid_queue/batch_execution.rb

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,9 @@ def create_all_from_jobs(jobs)
2424
})
2525

2626
total = jobs.size
27-
SolidQueue::Batch.upsert(
28-
{ batch_id:, total_jobs: total },
29-
**provider_upsert_options
30-
)
27+
SolidQueue::Batch.where(batch_id:).update_all(["total_jobs = total_jobs + ?", total])
3128
end
3229
end
33-
34-
private
35-
36-
def provider_upsert_options
37-
case connection.adapter_name
38-
when "PostgreSQL", "SQLite"
39-
{
40-
unique_by: :batch_id,
41-
on_duplicate: Arel.sql(
42-
"total_jobs = solid_queue_batches.total_jobs + excluded.total_jobs"
43-
)
44-
}
45-
else
46-
{
47-
on_duplicate: Arel.sql(
48-
"total_jobs = total_jobs + VALUES(total_jobs)"
49-
)
50-
}
51-
end
52-
end
5330
end
5431
end
5532
end

0 commit comments

Comments
 (0)