Fix #4957: Autotag non-web_source.
Autotag non-web_source on posts that have a non-http:// or https:// URL. Add a fix script to backfill old posts. Syntactically invalid URLs are still considered web sources. For example, `https://google,com` technically isn't a valid URL, but it's not considered a non-web source.
This commit is contained in:
25
script/fixes/089_add_non-web_source_tag.rb
Executable file
25
script/fixes/089_add_non-web_source_tag.rb
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require_relative "base"
|
||||
|
||||
CurrentUser.scoped(User.system) do
|
||||
Post.system_tag_match("-source:none -source:http://* -source:https://* -non-web_source").find_each do |post|
|
||||
puts "post ##{post.id}: adding non-web_source"
|
||||
post.save!
|
||||
end
|
||||
|
||||
Post.system_tag_match("source:none non-web_source").find_each do |post|
|
||||
puts "post ##{post.id}: removing non-web_source"
|
||||
post.save!
|
||||
end
|
||||
|
||||
Post.system_tag_match("source:http://* non-web_source").find_each do |post|
|
||||
puts "post ##{post.id}: removing non-web_source"
|
||||
post.save!
|
||||
end
|
||||
|
||||
Post.system_tag_match("source:https://* non-web_source").find_each do |post|
|
||||
puts "post ##{post.id}: removing non-web_source"
|
||||
post.save!
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user