Tag change notices
This adds a small notice at the bottom of post searches if a single tag search is the target of any tag change request.
This commit is contained in:
@@ -100,6 +100,30 @@ class AliasAndImplicationImporter
|
||||
end
|
||||
end
|
||||
|
||||
def affected_tags
|
||||
tokens = self.class.tokenize(text)
|
||||
tokens.inject([]) do |all, token|
|
||||
case token[0]
|
||||
when :create_alias, :remove_alias, :create_implication, :remove_implication
|
||||
all << token[1]
|
||||
all << token[2]
|
||||
all
|
||||
|
||||
when :mass_update
|
||||
all += Tag.scan_tags(token[1])
|
||||
all += Tag.scan_tags(token[2])
|
||||
all
|
||||
|
||||
when :change_category
|
||||
all << token[1]
|
||||
all
|
||||
|
||||
else
|
||||
all
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def parse(tokens, approver)
|
||||
|
||||
18
app/logical/tag_change_notice_service.rb
Normal file
18
app/logical/tag_change_notice_service.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
module TagChangeNoticeService
|
||||
extend self
|
||||
|
||||
def redis_client
|
||||
::Redis.new(url: Danbooru.config.redis_url)
|
||||
end
|
||||
|
||||
def get_forum_topic_id(tag)
|
||||
redis_client.get("tcn:#{tag}")
|
||||
end
|
||||
|
||||
def update_cache(affected_tags, forum_topic_id)
|
||||
rc = redis_client
|
||||
affected_tags.each do |tag|
|
||||
rc.setex("tcn:#{tag}", 1.week, forum_topic_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user