From 413f2e2b3e4b7b66ccab61494fc1a3191dc9bc05 Mon Sep 17 00:00:00 2001 From: Daniel Nitsikopoulos Date: Sun, 3 Mar 2024 19:46:15 +1100 Subject: [PATCH] Catch dead servers in archive bookmark job --- Gemfile | 1 + Gemfile.lock | 6 ++++-- lib/adamantium/jobs/archive_dead_bookmarks.rb | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 92ad789..fb83a5e 100644 --- a/Gemfile +++ b/Gemfile @@ -11,6 +11,7 @@ gem "hanami-validations", "2.1.0" gem "hanami-assets", "2.1.0" gem "hanami-view", "2.1.0" +gem "csv" gem "rom-sql" gem "pg" gem "scraperd", github: "dNitza/scraperd", branch: "master" diff --git a/Gemfile.lock b/Gemfile.lock index fb10c8e..4413966 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -68,6 +68,7 @@ GEM concurrent-ruby (1.2.3) connection_pool (2.4.1) crass (1.0.6) + csv (3.2.8) database_cleaner-core (2.0.1) database_cleaner-sequel (2.0.2) database_cleaner-core (~> 2.0.0) @@ -330,7 +331,7 @@ GEM parser (3.3.0.5) ast (~> 2.4.1) racc - pg (1.5.5) + pg (1.5.6) pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) @@ -441,7 +442,7 @@ GEM nokogiri (>= 1.12.0) sentry-ruby (5.16.1) concurrent-ruby (~> 1.0, >= 1.0.2) - sequel (5.77.0) + sequel (5.78.0) bigdecimal shellany (0.0.1) simple-rss (1.3.3) @@ -510,6 +511,7 @@ DEPENDENCIES capistrano-systemd-multiservice capistrano3-puma! connection_pool + csv database_cleaner-sequel dotenv down diff --git a/lib/adamantium/jobs/archive_dead_bookmarks.rb b/lib/adamantium/jobs/archive_dead_bookmarks.rb index 0df4cde..3f0bd27 100644 --- a/lib/adamantium/jobs/archive_dead_bookmarks.rb +++ b/lib/adamantium/jobs/archive_dead_bookmarks.rb @@ -1,5 +1,6 @@ require "httparty" require "que" +require "net/http" module Adamantium module Jobs @@ -14,6 +15,8 @@ module Adamantium if code >= 400 bookmark_repo.update(id: bookmark.id, params: {url: "https://web.archive.org/web/*/#{bookmark.url}"}) end + rescue Net::OpenTimeout + bookmark_repo.update(id: bookmark.id, params: {url: "https://web.archive.org/web/*/#{bookmark.url}"}) end end end