Skip to content

Commit

Permalink
Revert "AO3-6328 Try to fix large tags not updating in uses sort (#4637
Browse files Browse the repository at this point in the history
…)"

This reverts commit 4cacf7b.
  • Loading branch information
sarken authored Oct 17, 2023
1 parent 9705a64 commit 0aeda01
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
3 changes: 0 additions & 3 deletions app/models/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1133,9 +1133,6 @@ def after_update
end
end

# Ensure tags with count cache can be reindexed.
Rails.cache.delete(taggings_count_cache_key) if tag.saved_change_to_taggings_count_cache?

# Reindex immediately to update the unwrangled bin.
if tag.saved_change_to_unwrangleable?
tag.reindex_document
Expand Down
27 changes: 12 additions & 15 deletions spec/models/tag_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@
let(:tag) { create(:fandom) }
let!(:work) { create(:work, fandom_string: tag.name) }

before { run_update_tag_count_job }

def run_update_tag_count_job
before do
RedisJobSpawner.perform_now("TagCountUpdateJob")
tag.reload
end
Expand All @@ -107,7 +105,8 @@ def expect_tag_update_flag_in_redis_to_be(flag)
tag.taggings_count = 2
expect_tag_update_flag_in_redis_to_be(true)

run_update_tag_count_job
RedisJobSpawner.perform_now("TagCountUpdateJob")
tag.reload

# Actual number of taggings has not changed though count cache has.
expect(tag.taggings_count_cache).to eq 2
Expand All @@ -118,7 +117,8 @@ def expect_tag_update_flag_in_redis_to_be(flag)
create(:work, fandom_string: tag.name)
expect_tag_update_flag_in_redis_to_be(true)

run_update_tag_count_job
RedisJobSpawner.perform_now("TagCountUpdateJob")
tag.reload

expect(tag.taggings_count_cache).to eq 2
expect(tag.taggings_count).to eq 2
Expand All @@ -130,28 +130,25 @@ def expect_tag_update_flag_in_redis_to_be(flag)
REDIS_GENERAL.set("tag_update_#{tag.id}_value", "")
REDIS_GENERAL.sadd("tag_update", tag.id)

run_update_tag_count_job
RedisJobSpawner.perform_now("TagCountUpdateJob")

expect(tag.taggings_count_cache).to eq 1
expect(tag.reload.taggings_count_cache).to eq 1
end

it "triggers reindexing of tags which aren't used much" do
create(:work, fandom_string: tag.name)
expect { run_update_tag_count_job }
.to add_to_reindex_queue(tag, :main)

expect { RedisJobSpawner.perform_now("TagCountUpdateJob") }
.to add_to_reindex_queue(tag.reload, :main)
end

it "triggers reindexing of tags which are used significantly" do
ArchiveConfig.TAGGINGS_COUNT_MIN_CACHE_COUNT.times do
create(:work, fandom_string: tag.name)
end

expect { run_update_tag_count_job }
.to add_to_reindex_queue(tag, :main)
expect_tag_update_flag_in_redis_to_be(false)

create(:work, fandom_string: tag.name)
expect_tag_update_flag_in_redis_to_be(true)
expect { RedisJobSpawner.perform_now("TagCountUpdateJob") }
.to add_to_reindex_queue(tag.reload, :main)
end
end
end
Expand Down

0 comments on commit 0aeda01

Please sign in to comment.