commentaries: trim whitespace from existing commentaries.
This commit is contained in:
27
script/fixes/047_trim_artcomm_whitespace.rb
Executable file
27
script/fixes/047_trim_artcomm_whitespace.rb
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment'))
|
||||
|
||||
CurrentUser.user = User.system
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
|
||||
ArtistCommentary.without_timeout do
|
||||
ArtistCommentary.transaction do
|
||||
# binding.pry
|
||||
|
||||
artcomms = ArtistCommentary.where(%(
|
||||
original_title ~ '^[[:space:]]|[[:space:]]$'
|
||||
OR translated_title ~ '^[[:space:]]|[[:space:]]$'
|
||||
OR original_description ~ '^[[:space:]]|[[:space:]]$'
|
||||
OR translated_description ~ '^[[:space:]]|[[:space:]]$'
|
||||
))
|
||||
size = artcomms.size
|
||||
|
||||
artcomms.find_each.with_index do |artcomm, i|
|
||||
artcomm.save
|
||||
puts "#{i}/#{size}" if i % 100 == 0
|
||||
end
|
||||
|
||||
# raise ActiveRecord::Rollback
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user