Skip to content

Commit 2dcc162

Browse files
committed
make merging protips not throw exceptions when user was deleted because of spam
1 parent e3215fd commit 2dcc162

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/tasks/db.rake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ namespace :db do
216216

217217
task :protips => :connect do
218218
Protip.reset_pk_sequence
219+
not_ported = []
219220
Legacy[:protips].where(port_data_since).each do |row|
220221
puts "#{row[:id]} : #{row[:public_id]} : #{row[:slug]}"
221222
protip = Protip.find_or_initialize_by_id(row[:id])
@@ -234,9 +235,12 @@ namespace :db do
234235

235236
protip.flagged = row[:inappropriate].to_i > 0
236237

237-
protip.save!
238+
if !protip.save
239+
not_ported << protip
240+
end
238241
end
239242
Protip.reset_pk_sequence
243+
puts "Failed to port #{not_ported.size}"
240244
end
241245
end
242246

0 commit comments

Comments
 (0)