BURs: process BURs sequentially in a single job.
Change the way BURs are processed. Before, we spawned a background job for each line of the BUR, then processed each job sequentially. Now, we process the entire BUR sequentially in a single background job. This means that: * BURs are truly sequential now. Before certain things like removing aliases weren't actually performed in a background job, so they were performed out-of-order before everything else in the BUR. * Before, if an alias or implication line failed, then subsequent alias or implication lines would still be processed. This was because each alias or implication line was queued as a separate job, so a failure of one job didn't block another. Now, if any alias or implication fails, the entire BUR will fail and stop processing after that line. This may be good or bad, depending on whether we actually need the BUR to be processed in order or not. * Before, BURs were processed inside a database transaction (except for the actual updating of posts). Now they're not. This is because we can't afford to hold transactions open while processing long-running aliases or implications. This means that if BUR fails in the middle when it is initially approved, it will be left in a half-complete state. Before it would be rolled back and left in a pending state with no changes performed. * Before, only one BUR at a time could be processed. If multiple BURs were approved at the same time, then they would queue up and be processed one at a time. Now, multiple BURs can be processed at the same time. This may be undesirable when processing large BURs, or BURs that must be approved in a specific order. * Before, large tag category changes could time out. This was because they weren't actually performed in a background job. Now they are, so they shouldn't time out.
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
require "test_helper"
|
||||
|
||||
class TagBatchChangeJobTest < ActiveJob::TestCase
|
||||
context "a tag batch change" do
|
||||
setup do
|
||||
@user = create(:moderator_user)
|
||||
@post = create(:post, :tag_string => "aaa")
|
||||
end
|
||||
|
||||
should "execute" do
|
||||
TagBatchChangeJob.perform_now("aaa", "bbb")
|
||||
assert_equal("bbb", @post.reload.tag_string)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -205,6 +205,14 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
|
||||
assert_equal(false, @bur.valid?)
|
||||
assert_equal(["Can't remove alias foo -> bar (alias doesn't exist)"], @bur.errors[:base])
|
||||
end
|
||||
|
||||
should "be processed sequentially after the create alias command" do
|
||||
@bur = create_bur!("create alias foo -> bar\nremove alias foo -> bar", @admin)
|
||||
|
||||
@alias = TagAlias.find_by(antecedent_name: "foo", consequent_name: "bar")
|
||||
assert_equal(true, @alias.present?)
|
||||
assert_equal(true, @alias.is_deleted?)
|
||||
end
|
||||
end
|
||||
|
||||
context "the remove implication command" do
|
||||
@@ -231,6 +239,14 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
|
||||
assert_equal(false, @bur.valid?)
|
||||
assert_equal(["Can't remove implication foo -> bar (implication doesn't exist)"], @bur.errors[:base])
|
||||
end
|
||||
|
||||
should "be processed sequentially after the create implication command" do
|
||||
@bur = create_bur!("imply foo -> bar\nunimply foo -> bar", @admin)
|
||||
|
||||
@ti = TagImplication.find_by(antecedent_name: "foo", consequent_name: "bar")
|
||||
assert_equal(true, @ti.present?)
|
||||
assert_equal(true, @ti.is_deleted?)
|
||||
end
|
||||
end
|
||||
|
||||
context "the mass update command" do
|
||||
|
||||
Reference in New Issue
Block a user