saved searches: fix normalization of labels.
Fix saved searches to remove additional invalid characters from labels: * Remove repeated spaces or underscores. * Remove leading and trailing spaces or underscores. * Normalize Unicode characters to NFC form. Also add a fix script to renormalize labels in old saved searches. A few problems with existing searches: * Some saved searches somehow had labels containing NULL elements. * Some had leading or trailing underscores. * Some had repeated underscores. * Some had non-English characters in uppercase.
This commit is contained in:
15
script/fixes/070_renormalize_labels_in_saved_searches.rb
Executable file
15
script/fixes/070_renormalize_labels_in_saved_searches.rb
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require_relative "../../config/environment"
|
||||
|
||||
SavedSearch.transaction do
|
||||
SavedSearch.find_each do |ss|
|
||||
old_labels = ss.labels
|
||||
ss.labels = old_labels
|
||||
|
||||
if ss.changed?
|
||||
p [ss.id, ss.changes]
|
||||
ss.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user