Change hashtags to preserve first-used casing (#11416)

This commit is contained in:
Eugen Rochko
2019-07-28 05:59:51 +02:00
committed by GitHub
parent 4cc29eb5ad
commit f371b32137
6 changed files with 54 additions and 19 deletions

View File

@ -14,7 +14,7 @@ class HashtagQueryService < BaseService
private
def tags_for(tags)
Tag.where(name: tags.map(&:downcase)) if tags.presence
def tags_for(names)
Tag.matching_name(names) if names.presence
end
end

View File

@ -5,9 +5,7 @@ class ProcessHashtagsService < BaseService
tags = Extractor.extract_hashtags(status.text) if status.local?
records = []
tags.map { |str| str.mb_chars.downcase }.uniq(&:to_s).each do |name|
tag = Tag.where(name: name).first_or_create(name: name)
Tag.find_or_create_by_names(tags) do |tag|
status.tags << tag
records << tag