From 4a9fba8005e0a65c03198c674d2c65f7440d71a6 Mon Sep 17 00:00:00 2001
From: Bryan Newbold <bnewbold@archive.org>
Date: Wed, 21 Oct 2020 12:38:09 -0700
Subject: SQL: update weekly/quarterly ingest retry scripts

---
 sql/dump_reingest_quarterly.sql | 78 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 78 insertions(+)
 create mode 100644 sql/dump_reingest_quarterly.sql

(limited to 'sql/dump_reingest_quarterly.sql')

diff --git a/sql/dump_reingest_quarterly.sql b/sql/dump_reingest_quarterly.sql
new file mode 100644
index 0000000..303824b
--- /dev/null
+++ b/sql/dump_reingest_quarterly.sql
@@ -0,0 +1,78 @@
+
+COPY (
+    SELECT row_to_json(ingest_request.*) FROM ingest_request
+    LEFT JOIN ingest_file_result ON ingest_file_result.base_url = ingest_request.base_url
+    WHERE ingest_request.ingest_type = 'pdf'
+        AND ingest_file_result.ingest_type = 'pdf'
+        AND ingest_request.created < NOW() - '8 hour'::INTERVAL
+        AND ingest_request.created > NOW() - '91 day'::INTERVAL
+        AND ingest_file_result.hit = false
+        AND ingest_file_result.status like 'spn2-%'
+        AND ingest_file_result.status != 'spn2-error:invalid-url-syntax'
+        AND ingest_file_result.status != 'spn2-error:filesize-limit'
+        AND ingest_file_result.status != 'spn2-wayback-error'
+) TO '/grande/snapshots/reingest_quarterly_spn2-error_current.rows.json';
+
+COPY (
+    SELECT row_to_json(ingest_request.*) FROM ingest_request
+    LEFT JOIN ingest_file_result ON ingest_file_result.base_url = ingest_request.base_url
+    WHERE ingest_request.ingest_type = 'pdf'
+        AND ingest_file_result.ingest_type = 'pdf'
+        AND ingest_file_result.hit = false
+        AND ingest_file_result.status like 'cdx-error'
+        AND ingest_request.created < NOW() - '8 hour'::INTERVAL
+        AND ingest_request.created > NOW() - '91 day'::INTERVAL
+        AND (ingest_request.ingest_request_source = 'fatcat-changelog'
+             OR ingest_request.ingest_request_source = 'fatcat-ingest')
+) TO '/grande/snapshots/reingest_quarterly_cdx-error_current.rows.json';
+
+COPY (
+    SELECT row_to_json(ingest_request.*) FROM ingest_request
+    LEFT JOIN ingest_file_result ON ingest_file_result.base_url = ingest_request.base_url
+    WHERE ingest_request.ingest_type = 'pdf'
+        AND ingest_file_result.ingest_type = 'pdf'
+        AND ingest_file_result.hit = false
+        AND ingest_file_result.status like 'cdx-error'
+        AND ingest_request.created < NOW() - '8 hour'::INTERVAL
+        AND ingest_request.created > NOW() - '91 day'::INTERVAL
+        AND (ingest_request.ingest_request_source != 'fatcat-changelog'
+             AND ingest_request.ingest_request_source != 'fatcat-ingest')
+) TO '/grande/snapshots/reingest_quarterly_cdx-error_bulk_current.rows.json';
+
+COPY (
+    SELECT row_to_json(ingest_request.*) FROM ingest_request
+    LEFT JOIN ingest_file_result ON ingest_file_result.base_url = ingest_request.base_url
+    WHERE ingest_request.ingest_type = 'pdf'
+        AND ingest_file_result.ingest_type = 'pdf'
+        AND ingest_file_result.hit = false
+        AND ingest_file_result.status like 'wayback-error'
+        AND ingest_request.created < NOW() - '8 hour'::INTERVAL
+        AND ingest_request.created > NOW() - '91 day'::INTERVAL
+) TO '/grande/snapshots/reingest_quarterly_wayback-error_current.rows.json';
+
+COPY (
+    SELECT row_to_json(ingest_request.*) FROM ingest_request
+    LEFT JOIN ingest_file_result ON ingest_file_result.base_url = ingest_request.base_url
+    WHERE ingest_request.ingest_type = 'pdf'
+        AND ingest_file_result.ingest_type = 'pdf'
+        AND ingest_file_result.hit = false
+        AND ingest_file_result.status like 'gateway-timeout'
+        AND ingest_request.created < NOW() - '8 hour'::INTERVAL
+        AND ingest_request.created > NOW() - '91 day'::INTERVAL
+        AND (ingest_request.ingest_request_source = 'fatcat-changelog'
+             OR ingest_request.ingest_request_source = 'fatcat-ingest')
+) TO '/grande/snapshots/reingest_quarterly_gateway-timeout.rows.json';
+
+COPY (
+    SELECT row_to_json(ingest_request.*) FROM ingest_request
+    LEFT JOIN ingest_file_result ON ingest_file_result.base_url = ingest_request.base_url
+    WHERE ingest_request.ingest_type = 'pdf'
+        AND ingest_file_result.ingest_type = 'pdf'
+        AND ingest_file_result.hit = false
+        AND ingest_file_result.status like 'petabox-error'
+        AND ingest_request.created < NOW() - '8 hour'::INTERVAL
+        AND ingest_request.created > NOW() - '91 day'::INTERVAL
+        AND (ingest_request.ingest_request_source = 'fatcat-changelog'
+             OR ingest_request.ingest_request_source = 'fatcat-ingest')
+) TO '/grande/snapshots/reingest_quarterly_petabox-error_current.rows.json';
+
-- 
cgit v1.2.3

