Merge pull request #2986 from evazion/fix-ss-migrations

Fix broken tag subscription migrations.
This commit is contained in:
Albert Yi
2017-04-22 01:03:30 -07:00
committed by GitHub
4 changed files with 25 additions and 7 deletions

View File

@@ -112,6 +112,11 @@ class SavedSearch < ActiveRecord::Base
end
def label_string=(val)
self.labels = val.to_s.scan(/\S+/).map {|x| SavedSearch.normalize_label(x)}
self.labels = val.to_s.split(/[[:space:]]+/)
end
def labels=(labels)
labels = labels.map { |label| SavedSearch.normalize_label(label) }
super(labels)
end
end

View File

@@ -11,13 +11,8 @@ class TagSubscription < ActiveRecord::Base
def migrate_to_saved_searches
tag_query.split(/\r\n|\r|\n/).each do |query|
creator.saved_searches.create(
:tag_query => query,
:category => name
)
creator.saved_searches.create({query: query, labels: [name]}, without_protection: true)
end
destroy
end
def normalize_name