mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
REFACTOR: clean up mechanism
This commit is contained in:
parent
9fc3a335cc
commit
4825bf7e02
1 changed files with 5 additions and 3 deletions
|
@ -190,8 +190,10 @@ module Jobs
|
|||
|
||||
in_tran = false
|
||||
begin
|
||||
User.exec_sql("BEGIN TRANSACTION") unless Rails.env.test?
|
||||
in_tran = true
|
||||
unless Rails.env.test?
|
||||
User.exec_sql("BEGIN TRANSACTION")
|
||||
in_tran = true
|
||||
end
|
||||
i = 0
|
||||
rows.each do |row|
|
||||
if i % batch_size == 0 && i > 0
|
||||
|
@ -200,7 +202,7 @@ module Jobs
|
|||
User.exec_sql(sql_stmt, *row)
|
||||
i += 1
|
||||
end
|
||||
User.exec_sql("COMMIT") unless Rails.env.test?
|
||||
User.exec_sql("COMMIT") if in_tran
|
||||
rescue
|
||||
User.exec_sql("ROLLBACK") if in_tran
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue