-
Notifications
You must be signed in to change notification settings - Fork 789
AO3-6978 Create and fill new table for import urls #5795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3922114
a5641c4
06cb026
ee19458
27519b2
b72f2ea
c49e84f
766791c
c09e6ff
95a9553
2f89e65
81385a1
46ebd6b
3d0d165
50a0997
49c693e
138cea1
d26a5ab
354809d
77c37a5
b694c8a
a0716a0
df40d50
63f68b4
efc7a52
f0eaf92
5b304f2
3c52794
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,17 +7,24 @@ namespace :work_import_urls do | |
| scope = Work.where("imported_from_url IS NOT NULL AND imported_from_url != ''") | ||
| total = scope.count | ||
| processed = 0 | ||
| failed = 0 | ||
|
|
||
| puts "Backfilling #{total} work_import_urls records..." | ||
|
|
||
| scope.find_each(batch_size: batch_size) do |work| | ||
| next if ImportedUrl.exists?(work_id: work.id) | ||
|
|
||
| work.imported_url = ImportedUrl.create(original: work.imported_from_url) | ||
| begin | ||
| work.imported_url = ImportedUrl.create(original: work.imported_from_url) | ||
| rescue StandardError => e | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you update spec/lib/tasks/work_import_urls.rake_spec.rb with a test that shows the output for the error?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm trying to figure a way to do that. With the new limits in place the error won't hit since the original url can't be larger than 255 already. The largest I've gotten on the encoded column has been around 600 chars.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's okay -- it looks like we don't test the output for fully successful runs, either, so we can live without it. |
||
| puts "------- Error on import for work_id #{work.id}: #{e.inspect}" | ||
| failed += 1 | ||
| next | ||
| end | ||
| processed += 1 | ||
| puts "Processed #{processed}/#{total}" if (processed % batch_size).zero? | ||
| end | ||
|
|
||
| puts "Done! Backfilled #{processed} records." | ||
| puts "Done! Backfilled #{processed} records, failed #{failed} records." | ||
| end | ||
| end | ||
Uh oh!
There was an error while loading. Please reload this page.