burs/show: remove BUR update count estimate.
Remove the post update count estimate from BUR show pages. This was complex, slow, and usually inaccurate since it assumed that requests in a BUR had no overlap with each other, which usually wasn't the case.
This commit is contained in:
@@ -20,12 +20,6 @@ class TagBatchChangeJob < ApplicationJob
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.estimate_update_count(antecedent, consequent)
|
|
||||||
CurrentUser.without_safe_mode do
|
|
||||||
Post.tag_match(antecedent).count
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def migrate_posts(normalized_antecedent, normalized_consequent)
|
def migrate_posts(normalized_antecedent, normalized_consequent)
|
||||||
::Post.tag_match(normalized_antecedent.join(" ")).find_each do |post|
|
::Post.tag_match(normalized_antecedent.join(" ")).find_each do |post|
|
||||||
post.with_lock do
|
post.with_lock do
|
||||||
|
|||||||
@@ -78,24 +78,6 @@ class AliasAndImplicationImporter
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def estimate_update_count
|
|
||||||
tokens = self.class.tokenize(text)
|
|
||||||
tokens.map do |token|
|
|
||||||
case token[0]
|
|
||||||
when :create_alias
|
|
||||||
TagAlias.new(antecedent_name: token[1], consequent_name: token[2]).estimate_update_count
|
|
||||||
when :create_implication
|
|
||||||
TagImplication.new(antecedent_name: token[1], consequent_name: token[2]).estimate_update_count
|
|
||||||
when :mass_update
|
|
||||||
TagBatchChangeJob.estimate_update_count(token[1], token[2])
|
|
||||||
when :change_category
|
|
||||||
Tag.find_by_name(token[1]).try(:post_count) || 0
|
|
||||||
else
|
|
||||||
0
|
|
||||||
end
|
|
||||||
end.sum
|
|
||||||
end
|
|
||||||
|
|
||||||
def affected_tags
|
def affected_tags
|
||||||
tokens = self.class.tokenize(text)
|
tokens = self.class.tokenize(text)
|
||||||
tokens.inject([]) do |all, token|
|
tokens.inject([]) do |all, token|
|
||||||
|
|||||||
@@ -206,10 +206,6 @@ class BulkUpdateRequest < ApplicationRecord
|
|||||||
status == "rejected"
|
status == "rejected"
|
||||||
end
|
end
|
||||||
|
|
||||||
def estimate_update_count
|
|
||||||
AliasAndImplicationImporter.new(script, nil).estimate_update_count
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_notice
|
def update_notice
|
||||||
TagChangeNoticeService.update_cache(
|
TagChangeNoticeService.update_cache(
|
||||||
AliasAndImplicationImporter.new(script, nil).affected_tags,
|
AliasAndImplicationImporter.new(script, nil).affected_tags,
|
||||||
|
|||||||
@@ -198,10 +198,6 @@ class TagRelationship < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def estimate_update_count
|
|
||||||
Post.fast_count(antecedent_name, skip_cache: true)
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_posts
|
def update_posts
|
||||||
Post.without_timeout do
|
Post.without_timeout do
|
||||||
Post.raw_tag_match(antecedent_name).find_each do |post|
|
Post.raw_tag_match(antecedent_name).find_each do |post|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
<li><strong>Creator</strong> <%= link_to_user @bulk_update_request.user %></li>
|
<li><strong>Creator</strong> <%= link_to_user @bulk_update_request.user %></li>
|
||||||
<li><strong>Date</strong> <%= @bulk_update_request.created_at %></li>
|
<li><strong>Date</strong> <%= @bulk_update_request.created_at %></li>
|
||||||
<li><strong>Status</strong>: <%= @bulk_update_request.status %></li>
|
<li><strong>Status</strong>: <%= @bulk_update_request.status %></li>
|
||||||
<li><strong title="How many posts will be affected">Estimate</strong>: <%= @bulk_update_request.estimate_update_count %></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div style="margin: 1em 0;">
|
<div style="margin: 1em 0;">
|
||||||
|
|||||||
@@ -7,12 +7,6 @@ class TagBatchChangeJobTest < ActiveJob::TestCase
|
|||||||
@post = create(:post, :tag_string => "aaa")
|
@post = create(:post, :tag_string => "aaa")
|
||||||
end
|
end
|
||||||
|
|
||||||
context "#estimate_update_count" do
|
|
||||||
should "find the correct count" do
|
|
||||||
assert_equal(1, TagBatchChangeJob.estimate_update_count("aaa", "bbb"))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
should "execute" do
|
should "execute" do
|
||||||
TagBatchChangeJob.perform_now("aaa", "bbb", @user, "127.0.0.1")
|
TagBatchChangeJob.perform_now("aaa", "bbb", @user, "127.0.0.1")
|
||||||
assert_equal("bbb", @post.reload.tag_string)
|
assert_equal("bbb", @post.reload.tag_string)
|
||||||
|
|||||||
@@ -48,28 +48,6 @@ class AliasAndImplicationImporterTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "#estimate_update_count" do
|
|
||||||
setup do
|
|
||||||
FactoryBot.create(:post, tag_string: "aaa")
|
|
||||||
FactoryBot.create(:post, tag_string: "bbb")
|
|
||||||
FactoryBot.create(:post, tag_string: "ccc")
|
|
||||||
FactoryBot.create(:post, tag_string: "ddd")
|
|
||||||
FactoryBot.create(:post, tag_string: "eee")
|
|
||||||
|
|
||||||
@script = "create alias aaa -> 000\n" +
|
|
||||||
"create implication bbb -> 111\n" +
|
|
||||||
"remove alias ccc -> 222\n" +
|
|
||||||
"remove implication ddd -> 333\n" +
|
|
||||||
"mass update eee -> 444\n"
|
|
||||||
end
|
|
||||||
|
|
||||||
subject { AliasAndImplicationImporter.new(@script, nil) }
|
|
||||||
|
|
||||||
should "return the correct count" do
|
|
||||||
assert_equal(3, subject.estimate_update_count)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "given a valid list" do
|
context "given a valid list" do
|
||||||
setup do
|
setup do
|
||||||
@list = "create alias abc -> def\ncreate implication aaa -> bbb\n"
|
@list = "create alias abc -> def\ncreate implication aaa -> bbb\n"
|
||||||
|
|||||||
@@ -13,28 +13,6 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
|
|||||||
CurrentUser.ip_addr = nil
|
CurrentUser.ip_addr = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
context "#estimate_update_count" do
|
|
||||||
setup do
|
|
||||||
FactoryBot.create(:post, tag_string: "aaa")
|
|
||||||
FactoryBot.create(:post, tag_string: "bbb")
|
|
||||||
FactoryBot.create(:post, tag_string: "ccc")
|
|
||||||
FactoryBot.create(:post, tag_string: "ddd")
|
|
||||||
FactoryBot.create(:post, tag_string: "eee")
|
|
||||||
|
|
||||||
@script = "create alias aaa -> 000\n" +
|
|
||||||
"create implication bbb -> 111\n" +
|
|
||||||
"remove alias ccc -> 222\n" +
|
|
||||||
"remove implication ddd -> 333\n" +
|
|
||||||
"mass update eee -> 444\n"
|
|
||||||
end
|
|
||||||
|
|
||||||
subject { BulkUpdateRequest.new(script: @script) }
|
|
||||||
|
|
||||||
should "return the correct count" do
|
|
||||||
assert_equal(3, subject.estimate_update_count)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "#update_notice" do
|
context "#update_notice" do
|
||||||
setup do
|
setup do
|
||||||
@forum_topic = create(:forum_topic, creator: @admin)
|
@forum_topic = create(:forum_topic, creator: @admin)
|
||||||
|
|||||||
@@ -57,17 +57,6 @@ class TagAliasTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "#estimate_update_count" do
|
|
||||||
setup do
|
|
||||||
FactoryBot.create(:post, tag_string: "aaa bbb ccc")
|
|
||||||
@alias = FactoryBot.create(:tag_alias, antecedent_name: "aaa", consequent_name: "bbb", status: "pending")
|
|
||||||
end
|
|
||||||
|
|
||||||
should "get the right count" do
|
|
||||||
assert_equal(1, @alias.estimate_update_count)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "#update_notice" do
|
context "#update_notice" do
|
||||||
setup do
|
setup do
|
||||||
@forum_topic = FactoryBot.create(:forum_topic)
|
@forum_topic = FactoryBot.create(:forum_topic)
|
||||||
|
|||||||
@@ -53,17 +53,6 @@ class TagImplicationTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "#estimate_update_count" do
|
|
||||||
setup do
|
|
||||||
FactoryBot.create(:post, tag_string: "aaa bbb ccc")
|
|
||||||
@implication = FactoryBot.create(:tag_implication, antecedent_name: "aaa", consequent_name: "bbb", status: "pending")
|
|
||||||
end
|
|
||||||
|
|
||||||
should "get the right count" do
|
|
||||||
assert_equal(1, @implication.estimate_update_count)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "#update_notice" do
|
context "#update_notice" do
|
||||||
setup do
|
setup do
|
||||||
@forum_topic = FactoryBot.create(:forum_topic)
|
@forum_topic = FactoryBot.create(:forum_topic)
|
||||||
|
|||||||
Reference in New Issue
Block a user