File tree Expand file tree Collapse file tree 1 file changed +18
-13
lines changed
app/models/hackathon/website Expand file tree Collapse file tree 1 file changed +18
-13
lines changed Original file line number Diff line number Diff line change @@ -24,25 +24,30 @@ def archive_website
2424 request = capture . request
2525
2626 if request [ "status" ] == "error"
27- Rails . logger . info "Internet Archive returned an error capturing #{ website } :"
28- Rails . logger . info request [ "message" ]
29- return
27+ Rails . logger . warn "Internet Archive returned an error capturing #{ website } :"
28+ Rails . logger . warn request [ "message" ]
29+ else
30+ follow_up
3031 end
32+ end
3133
32- begin
33- Timeout . timeout ( 3 . minutes ) do
34- sleep 5 until capture . finished?
35- end
36-
37- record :archived_website if capture . finished?
38- rescue Timeout ::Error
39- Rails . logger . info "Timed out waiting for Internet Archive to finish capture for #{ website } with job #{ capture . job_id } ."
34+ def follow_up_on_archive ( job_id )
35+ if archive_with ( job_id ) . finished?
36+ record :website_archived
37+ else
38+ Rails . logger . warn "Internet Archive didn't finish capture for #{ website } with job #{ capture . job_id } ."
4039 end
4140 end
4241
4342 private
4443
45- def archive_website_later
46- Hackathons ::WebsiteArchivalJob . perform_later ( self )
44+ def archive_with ( job_id )
45+ InternetArchive ::Capture . new ( job_id :)
46+ end
47+
48+ class FollowUpJob < ApplicationJob
49+ def perform ( hackathon , id )
50+ hackathon . follow_up_on_archive ( id )
51+ end
4752 end
4853end
You can’t perform that action at this time.
0 commit comments