Merge commit '0dac31dfd588e4cd866f382ed001a9535f06234a' into glitch-soc/merge-upstream
This commit is contained in:
commit
c8f365fd1d
79 files changed
+843
-227
No files matched your search
@@ -50,12 +50,20 @@ class Collection < ApplicationRecord
|
||||
result
|
||||
end
|
||||
|
||||
def tag_name
|
||||
tag&.formatted_name
|
||||
end
|
||||
|
||||
def tag_name=(new_name)
|
||||
self.tag = Tag.find_or_create_by_names(new_name).first
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def tag_is_usable
|
||||
return if tag.blank?
|
||||
|
||||
errors.add(:tag, :unusable) unless tag.usable?
|
||||
errors.add(:tag_name, :unusable) unless tag.usable?
|
||||
end
|
||||
|
||||
def items_do_not_exceed_limit
|
||||
|
||||
+3
-4
@@ -67,6 +67,8 @@ class Tag < ApplicationRecord
|
||||
}
|
||||
scope :matches_name, ->(term) { where(arel_table[:name].lower.matches(arel_table.lower("#{sanitize_sql_like(Tag.normalize(term))}%"), nil, true)) } # Search with case-sensitive to use B-tree index
|
||||
|
||||
normalizes :display_name, with: ->(value) { value.gsub(HASHTAG_INVALID_CHARS_RE, '') }
|
||||
|
||||
update_index('tags', :self)
|
||||
|
||||
def to_param
|
||||
@@ -113,10 +115,7 @@ class Tag < ApplicationRecord
|
||||
|
||||
names.map do |(normalized_name, display_name)|
|
||||
tag = begin
|
||||
matching_name(normalized_name).first || create!(
|
||||
name: normalized_name,
|
||||
display_name: display_name.gsub(HASHTAG_INVALID_CHARS_RE, '')
|
||||
)
|
||||
matching_name(normalized_name).first || create!(name: normalized_name, display_name:)
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
find_normalized(normalized_name)
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user