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:
evazion
2021-01-09 21:18:43 -06:00
parent 7fbac34962
commit e788d8d0b6
3 changed files with 47 additions and 20 deletions

View 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