forked from e621ng/e621ng
fix tag alias correction tests
also removes references to distributed memcached servers in tag alias correction
This commit is contained in:
parent
d32882e1ee
commit
6f30c99ac3
@ -1,11 +1,10 @@
|
||||
class TagAliasCorrection
|
||||
attr_reader :tag_alias_id, :tag_alias, :hostname
|
||||
attr_reader :tag_alias_id, :tag_alias
|
||||
delegate :antecedent_name, :consequent_name, :to => :tag_alias
|
||||
|
||||
def initialize(tag_alias_id, hostname = Socket.gethostname)
|
||||
def initialize(tag_alias_id)
|
||||
@tag_alias_id = tag_alias_id
|
||||
@tag_alias = TagAlias.find(tag_alias_id)
|
||||
@hostname = hostname
|
||||
end
|
||||
|
||||
def to_json(options = {})
|
||||
@ -21,27 +20,6 @@ class TagAliasCorrection
|
||||
}
|
||||
end
|
||||
|
||||
def fill_hash!
|
||||
res = HTTParty.get("https://#{hostname}.#{Danbooru.config.domain}/tag_aliases/#{tag_alias_id}/correction.json", Danbooru.config.httparty_options)
|
||||
if res.success?
|
||||
json = JSON.parse(res.body)
|
||||
statistics_hash["antecedent_cache"] = json["antecedent_cache"]
|
||||
statistics_hash["consequent_cache"] = json["consequent_cache"]
|
||||
end
|
||||
end
|
||||
|
||||
def each_server
|
||||
Danbooru.config.all_server_hosts.each do |host|
|
||||
other = TagAliasCorrection.new(tag_alias_id, host)
|
||||
|
||||
if host != Socket.gethostname
|
||||
other.fill_hash!
|
||||
end
|
||||
|
||||
yield other
|
||||
end
|
||||
end
|
||||
|
||||
def clear_cache
|
||||
tag_alias.clear_all_cache
|
||||
end
|
||||
|
@ -4,17 +4,14 @@
|
||||
|
||||
<p>Because tag aliases are cached in memory, they may go out of sync. This action will clear out the cache and fix any lingering posts.</p>
|
||||
|
||||
<% @correction.each_server do |server| %>
|
||||
<div style="margin-bottom: 1em;">
|
||||
<h2>Server: <%= server.hostname %></h2>
|
||||
<ul>
|
||||
<li><strong><%= link_to server.antecedent_name, posts_path(:tags => server.antecedent_name, :raw => true) %></strong> aliased to <strong><%= server.statistics_hash["antecedent_cache"] %></strong> in cache</li>
|
||||
<li><strong><%= server.consequent_name %></strong> aliased to <strong><%= server.statistics_hash["consequent_cache"] %></strong> in cache</li>
|
||||
<li><strong><%= server.antecedent_name %></strong> count is <%= server.statistics_hash["antecedent_count"] %></li>
|
||||
<li><strong><%= server.consequent_name %></strong> count is <%= server.statistics_hash["consequent_count"] %></li>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
<div style="margin-bottom: 1em;">
|
||||
<ul>
|
||||
<li><strong><%= link_to @correction.antecedent_name, posts_path(:tags => @correction.antecedent_name, :raw => true) %></strong> aliased to <strong><%= @correction.statistics_hash["antecedent_cache"] %></strong> in cache</li>
|
||||
<li><strong><%= @correction.consequent_name %></strong> aliased to <strong><%= @correction.statistics_hash["consequent_cache"] %></strong> in cache</li>
|
||||
<li><strong><%= @correction.antecedent_name %></strong> count is <%= @correction.statistics_hash["antecedent_count"] %></li>
|
||||
<li><strong><%= @correction.consequent_name %></strong> count is <%= @correction.statistics_hash["consequent_count"] %></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<p>You can try to fix this alias. This will clear the cache and re-save all posts associated with <strong><%= @correction.antecedent_name %></strong>.</p>
|
||||
|
||||
|
@ -8,6 +8,7 @@ class TagAliasCorrectionTest < ActiveSupport::TestCase
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
@post = FactoryBot.create(:post, :tag_string => "aaa")
|
||||
@tag_alias = FactoryBot.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb")
|
||||
@tag_alias.update_posts
|
||||
end
|
||||
|
||||
teardown do
|
||||
|
Loading…
Reference in New Issue
Block a user