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:
Albert Yi
2019-01-14 18:14:27 -08:00
parent 60f0aeeb99
commit 1550538dc1
10 changed files with 143 additions and 0 deletions

View File

@@ -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)

View 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