aboutsummaryrefslogtreecommitdiffstats
path: root/notes/ingest/2021-09-03_patch_crawl.md
blob: e664c16b3b31960faf0c6ef665a346c32290aa60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643

Going to run a combined crawl for `no-capture`, `no-pdf-link` and similar URL
statuses.

As a reminder, significant refactor of PDF URL extraction happened around
Oct/Nov 2020, so things not re-ingested since then should be retried.

1. first bulk re-process `no-pdf-link` statuses from OAI-PMH crawl past OA DOI past crawls
2. then heritrix crawl of old URLs from all sources (see status codes below)
3. bulk ingest specific sources and statuses (see below)

Status codes to crawl, with potentially split separate batches:

    no-capture
    IA errors
      cdx-error
      wayback-error
      wayback-content-error
      petabox-error
      spn2-cdx-lookup-failure
    gateway-timeout

Then, bulk ingest from these sources matching the above patterns, in this order:

- OA DOI (fatcat-ingest or fatcat-changelog source; will result in import)
- unpaywall (will result in import)
- OAI-PMH
- MAG

Current combined domain skip list (SQL filter syntax), for which we don't want
to bother retrying:

    '%journals.sagepub.com%'
    '%pubs.acs.org%'
    '%ahajournals.org%'
    '%www.journal.csj.jp%'
    '%aip.scitation.org%'
    '%academic.oup.com%'
    '%tandfonline.com%'
    '%://orcid.org/%'
    '%://doaj.org/%'
    '%://archive.org/%'
    '%://web.archive.org/%'
    '%://www.archive.org/%'

## DOI Ingest Status (2021-09-08)

Recently did some analysis of OAI-PMH overall status, so can re-do comparisons
there easily. What about overall DOI ingest? Would like counts so we can
compare before/after.

    SELECT ingest_file_result.status, COUNT(*)
    FROM ingest_request
    LEFT JOIN ingest_file_result
        ON ingest_file_result.ingest_type = ingest_request.ingest_type
        AND ingest_file_result.base_url = ingest_request.base_url
    WHERE 
        ingest_request.ingest_type = 'pdf'
        AND ingest_request.link_source = 'doi'
        AND (
            ingest_request.ingest_request_source = 'fatcat-ingest'
            OR ingest_request.ingest_request_source = 'fatcat-changelog'
        )
    GROUP BY status
    ORDER BY COUNT DESC
    LIMIT 20;

                status             |  count
    -------------------------------+----------
     no-pdf-link                   | 10516478
     success                       |  5690862
     redirect-loop                 |  1827192
     no-capture                    |  1215179
     terminal-bad-status           |   650104
     link-loop                     |   610251
     blocked-cookie                |   353681
     gateway-timeout               |   341319
     too-many-redirects            |   307895
     forbidden                     |   306710
     spn2-cdx-lookup-failure       |   282955
     not-found                     |   273667
     cdx-error                     |   269082
     skip-url-blocklist            |   265689
     spn2-error                    |    87759
     wrong-mimetype                |    68993
     spn2-error:too-many-redirects |    58064
     wayback-error                 |    54152
     spn2-wayback-error            |    51752
     remote-server-error           |    45683
    (20 rows)

## `no-pdf-link` re-try bulk ingest

Specifically for past OAI-PMH and OA DOI crawls.

What are top terminal domains that would be retried? So that we can filter out
large ones we don't want to bother retrying.

    SELECT domain, COUNT(domain)
    FROM (
        SELECT
            substring(ingest_file_result.terminal_url FROM '[^/]+://([^/]*)') AS domain
        FROM ingest_request
        LEFT JOIN ingest_file_result 
            ON ingest_file_result.ingest_type = ingest_request.ingest_type
            AND ingest_file_result.base_url = ingest_request.base_url
        WHERE
            ingest_request.ingest_type = 'pdf'
            AND ingest_file_result.status = 'no-pdf-link'
            AND (
                ingest_request.link_source = 'oai'
                OR (
                    ingest_request.link_source = 'doi'
                    AND (
                        ingest_request.ingest_request_source = 'fatcat-ingest'
                        OR ingest_request.ingest_request_source = 'fatcat-changelog'
                    )
                )
            )

            AND ingest_request.link_source_id NOT LIKE 'oai:kb.dk:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:bdr.oai.bsb-muenchen.de:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:hispana.mcu.es:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:bnf.fr:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:ukm.si:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:biodiversitylibrary.org:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:hsp.org:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:repec:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:n/a:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:quod.lib.umich.edu:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:americanae.aecid.es:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:www.irgrid.ac.cn:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:espace.library.uq.edu:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:edoc.mpg.de:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:bibliotecadigital.jcyl.es:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:repository.erciyes.edu.tr:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:krm.or.kr:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:hypotheses.org:%'

            AND ingest_file_result.terminal_url NOT LIKE '%mdz-nbn-resolving.de%'
            AND ingest_file_result.terminal_url NOT LIKE '%edoc.mpg.de%'
            AND ingest_file_result.terminal_url NOT LIKE '%doaj.org%'
            AND ingest_file_result.terminal_url NOT LIKE '%orcid.org%'
            AND ingest_file_result.terminal_url NOT LIKE '%gateway.isiknowledge.com%'
            AND ingest_file_result.terminal_url NOT LIKE '%europmc.org%'
            AND ingest_file_result.terminal_url NOT LIKE '%arxiv.org%'
            AND ingest_file_result.terminal_url NOT LIKE 'https://doi.org/10.%'
    ) t1
    WHERE t1.domain != ''
    GROUP BY domain
    ORDER BY COUNT DESC
    LIMIT 40;

                    domain                 | count  
    ---------------------------------------+--------
     ssl.fao.org                           | 862277
     www.e-periodica.ch                    | 828110
     zenodo.org                            | 686701
     plutof.ut.ee                          | 685440
     www.gbif.org                          | 669727
     dlc.library.columbia.edu              | 536018
     figshare.com                          | 383181
     juser.fz-juelich.de                   | 351519
     statisticaldatasets.data-planet.com   | 320415
     espace.library.uq.edu.au              | 310767
     invenio.nusl.cz                       | 309731
     doi.pangaea.de                        | 306311
     igi.indrastra.com                     | 297872
     bib-pubdb1.desy.de                    | 273565
     t2r2.star.titech.ac.jp                | 271907
     digi.ub.uni-heidelberg.de             | 265519
     www.sciencedirect.com                 | 263847
     publikationen.bibliothek.kit.edu      | 229960
     www.plate-archive.org                 | 209231
     www.degruyter.com                     | 189776
     spectradspace.lib.imperial.ac.uk:8443 | 187086
     hal.archives-ouvertes.fr              | 185513
     open.library.ubc.ca                   | 172821
     lup.lub.lu.se                         | 170063
     books.openedition.org                 | 169501
     orbi.uliege.be                        | 161443
     freidok.uni-freiburg.de               | 150310
     library.wur.nl                        | 124318
     digital.library.pitt.edu              | 116406
     www.research.manchester.ac.uk         | 115869
     www.bibliotecavirtualdeandalucia.es   | 114527
     repository.tue.nl                     | 112157
     www.google.com                        | 111569
     easy.dans.knaw.nl                     | 109608
     springernature.figshare.com           | 108597
     nbn-resolving.org                     | 107544
     scholarbank.nus.edu.sg                | 107299
     bibliotecavirtualdefensa.es           | 105501
     biblio.ugent.be                       | 100854
     ruj.uj.edu.pl                         |  99500
    (40 rows)

For a number of these domains, we do not expect any PDFs to be found, but are
going to re-ingest anyways so they get marked as 'blocked-*' in result table:

- ssl.fao.org
- plutof.ut.ee
- www.gbif.org

But some we are just going to skip anyways, because there *could* be PDFs, but
probably *aren't*:

- zenodo.org
- t2r2.star.titech.ac.jp
- www.google.com
- figshare.com
- springernature.figshare.com

Dump ingest requests:

    COPY (  
        SELECT row_to_json(ingest_request.*)
        FROM ingest_request
        LEFT JOIN ingest_file_result
            ON ingest_file_result.ingest_type = ingest_request.ingest_type
            AND ingest_file_result.base_url = ingest_request.base_url
        WHERE
            ingest_request.ingest_type = 'pdf'
            AND ingest_file_result.status = 'no-pdf-link'
            AND (
                ingest_request.link_source = 'oai'
                OR (
                    ingest_request.link_source = 'doi'
                    AND (
                        ingest_request.ingest_request_source = 'fatcat-ingest'
                        OR ingest_request.ingest_request_source = 'fatcat-changelog'
                    )
                )
            )

            AND ingest_request.link_source_id NOT LIKE 'oai:kb.dk:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:bdr.oai.bsb-muenchen.de:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:hispana.mcu.es:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:bnf.fr:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:ukm.si:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:biodiversitylibrary.org:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:hsp.org:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:repec:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:n/a:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:quod.lib.umich.edu:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:americanae.aecid.es:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:www.irgrid.ac.cn:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:espace.library.uq.edu:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:edoc.mpg.de:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:bibliotecadigital.jcyl.es:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:repository.erciyes.edu.tr:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:krm.or.kr:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:hypotheses.org:%'

            AND ingest_file_result.terminal_url NOT LIKE '%mdz-nbn-resolving.de%'
            AND ingest_file_result.terminal_url NOT LIKE '%edoc.mpg.de%'
            AND ingest_file_result.terminal_url NOT LIKE '%doaj.org%'
            AND ingest_file_result.terminal_url NOT LIKE '%orcid.org%'
            AND ingest_file_result.terminal_url NOT LIKE '%gateway.isiknowledge.com%'
            AND ingest_file_result.terminal_url NOT LIKE '%europmc.org%'
            AND ingest_file_result.terminal_url NOT LIKE '%arxiv.org%'
            AND ingest_file_result.terminal_url NOT LIKE 'https://doi.org/10.%'

            AND ingest_file_result.terminal_url NOT LIKE '%journals.sagepub.com%'
            AND ingest_file_result.terminal_url NOT LIKE '%pubs.acs.org%'
            AND ingest_file_result.terminal_url NOT LIKE '%ahajournals.org%'
            AND ingest_file_result.terminal_url NOT LIKE '%www.journal.csj.jp%'
            AND ingest_file_result.terminal_url NOT LIKE '%aip.scitation.org%'
            AND ingest_file_result.terminal_url NOT LIKE '%academic.oup.com%'
            AND ingest_file_result.terminal_url NOT LIKE '%tandfonline.com%'
            AND ingest_file_result.terminal_url NOT LIKE '%researchgate.net%'
            AND ingest_file_result.terminal_url NOT LIKE '%muse.jhu.edu%'
            AND ingest_file_result.terminal_url NOT LIKE '%omicsonline.org%'
            AND ingest_file_result.terminal_url NOT LIKE '%link.springer.com%'
            AND ingest_file_result.terminal_url NOT LIKE '%ieeexplore.ieee.org%'

            AND ingest_file_result.terminal_url NOT LIKE '%zenodo.org%'
            AND ingest_file_result.terminal_url NOT LIKE '%t2r2.star.titech.ac.jp%'
            AND ingest_file_result.terminal_url NOT LIKE '%www.google.com%'
            AND ingest_file_result.terminal_url NOT LIKE '%figshare.com%'
            AND ingest_file_result.terminal_url NOT LIKE '%springernature.figshare.com%'
    ) TO '/srv/sandcrawler/tasks/patch_ingest_request_2021-09-08.rows.json';
    => COPY 18040676

Transform and start ingest:

    ./scripts/ingestrequest_row2json.py /srv/sandcrawler/tasks/patch_ingest_request_2021-09-08.rows.json | pv -l | shuf > /srv/sandcrawler/tasks/patch_ingest_request_2021-09-08.ingest_request.json
    => 18.0M 0:06:45 [44.5k/s]

    cat /srv/sandcrawler/tasks/patch_ingest_request_2021-09-08.ingest_request.json | rg -v "\\\\" | jq . -c | kafkacat -P -b wbgrp-svc263.us.archive.org -t sandcrawler-prod.ingest-file-requests -p -1
    => DONE

## Progress Check

OAI-PMH query:

    SELECT ingest_file_result.status, COUNT(*)
    FROM ingest_request
    LEFT JOIN ingest_file_result
        ON ingest_file_result.ingest_type = ingest_request.ingest_type
        AND ingest_file_result.base_url = ingest_request.base_url
    WHERE 
        ingest_request.ingest_type = 'pdf'
        AND ingest_request.link_source = 'oai'
        AND ingest_request.link_source_id NOT LIKE 'oai:kb.dk:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:bdr.oai.bsb-muenchen.de:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:hispana.mcu.es:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:bnf.fr:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:ukm.si:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:biodiversitylibrary.org:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:hsp.org:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:repec:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:n/a:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:quod.lib.umich.edu:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:americanae.aecid.es:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:www.irgrid.ac.cn:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:espace.library.uq.edu:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:edoc.mpg.de:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:bibliotecadigital.jcyl.es:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:repository.erciyes.edu.tr:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:krm.or.kr:%'
        AND ingest_request.base_url NOT LIKE '%www.kb.dk%'
        AND ingest_request.base_url NOT LIKE '%kb-images.kb.dk%'
        AND ingest_request.base_url NOT LIKE '%mdz-nbn-resolving.de%'
        AND ingest_request.base_url NOT LIKE '%aggr.ukm.um.si%'
        AND ingest_request.base_url NOT LIKE '%edoc.mpg.de%'
        AND ingest_request.base_url NOT LIKE '%doaj.org%'
        AND ingest_request.base_url NOT LIKE '%orcid.org%'
        AND ingest_request.base_url NOT LIKE '%gateway.isiknowledge.com%'
        AND ingest_request.link_source_id NOT LIKE 'oai:hypotheses.org:%'
    GROUP BY status
    ORDER BY COUNT DESC
    LIMIT 20;

             status          |  count   
    -------------------------+----------
     success                 | 13258356
     no-pdf-link             |  8685519
     no-capture              |  4765663
     redirect-loop           |  1557731
     terminal-bad-status     |   803373
     link-loop               |   453999
     wrong-mimetype          |   440230
     null-body               |    71457
     cdx-error               |    18426
                             |    15275
     petabox-error           |    13408
     wayback-error           |    11845
     blocked-cookie          |    11580
     skip-url-blocklist      |     7761
     wayback-content-error   |      383
     spn2-cdx-lookup-failure |      362
     gateway-timeout         |      320
     body-too-large          |      207
     spn2-error:job-failed   |      191
     redirects-exceeded      |      120
    (20 rows)

OAI-PMH compared to a couple weeks ago:

    13258356-12872279 = +386,077 success
    8685519-9329602 =   -644,083 no-pdf-link
    4765663-4696362 =    +69,301 no-capture
    803373-660418 =     +142,955 terminal-bad-status

OA DOI ingest:

    SELECT ingest_file_result.status, COUNT(*)
    FROM ingest_request
    LEFT JOIN ingest_file_result
        ON ingest_file_result.ingest_type = ingest_request.ingest_type
        AND ingest_file_result.base_url = ingest_request.base_url
    WHERE 
        ingest_request.ingest_type = 'pdf'
        AND ingest_request.link_source = 'doi'
        AND (
            ingest_request.ingest_request_source = 'fatcat-ingest'
            OR ingest_request.ingest_request_source = 'fatcat-changelog'
        )
    GROUP BY status
    ORDER BY COUNT DESC
    LIMIT 20;


                status             |  count  
    -------------------------------+---------
     no-pdf-link                   | 6693547
     success                       | 5979016
     skip-url-blocklist            | 3080986
     no-capture                    | 1876914
     redirect-loop                 | 1872817
     terminal-bad-status           |  656674
     link-loop                     |  624290
     blocked-cookie                |  448001
     gateway-timeout               |  351896
     too-many-redirects            |  307895
     forbidden                     |  306710
     spn2-cdx-lookup-failure       |  301312
     cdx-error                     |  279766
     not-found                     |  273667
     wrong-mimetype                |   83289
     spn2-error                    |   76806
     spn2-error:too-many-redirects |   58064
     wayback-error                 |   54278
     spn2-wayback-error            |   51768
     remote-server-error           |   45683
    (20 rows)

OA DOI changes:

    5979016-5690862 =    +288,154   success
    6693547-10516478 = -3,822,931   no-pdf-link (still many!)
    1876914-1215179 =    +661,735   no-capture
    3080986-265689 =   +2,815,297   skip-url-blocklist

Overall about half a million new 'success', pretty good. over 750k new
no-capture for crawling.

## Seedlist Dumps

Note that this is just seedlists, not full ingest requests.

    COPY (  
        SELECT ingest_file_result.terminal_url
        FROM ingest_request
        LEFT JOIN ingest_file_result
            ON ingest_file_result.ingest_type = ingest_request.ingest_type
            AND ingest_file_result.base_url = ingest_request.base_url
        WHERE
            ingest_request.ingest_type = 'pdf'
            AND (
                ingest_file_result.status = 'no-capture'
                OR ingest_file_result.status = 'cdx-error'
                OR ingest_file_result.status = 'wayback-error'
                OR ingest_file_result.status = 'wayback-content-error'
                OR ingest_file_result.status = 'petabox-error'
                OR ingest_file_result.status = 'spn2-cdx-lookup-failure'
                OR ingest_file_result.status = 'gateway-timeout'
            )
            AND ingest_request.link_source_id NOT LIKE 'oai:kb.dk:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:bdr.oai.bsb-muenchen.de:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:hispana.mcu.es:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:bnf.fr:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:ukm.si:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:biodiversitylibrary.org:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:hsp.org:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:repec:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:n/a:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:quod.lib.umich.edu:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:americanae.aecid.es:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:www.irgrid.ac.cn:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:espace.library.uq.edu:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:edoc.mpg.de:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:bibliotecadigital.jcyl.es:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:repository.erciyes.edu.tr:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:krm.or.kr:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:hypotheses.org:%'

            AND ingest_file_result.terminal_url NOT LIKE '%mdz-nbn-resolving.de%'
            AND ingest_file_result.terminal_url NOT LIKE '%edoc.mpg.de%'
            AND ingest_file_result.terminal_url NOT LIKE '%doaj.org%'
            AND ingest_file_result.terminal_url NOT LIKE '%orcid.org%'
            AND ingest_file_result.terminal_url NOT LIKE '%gateway.isiknowledge.com%'
            AND ingest_file_result.terminal_url NOT LIKE '%europmc.org%'
            AND ingest_file_result.terminal_url NOT LIKE '%arxiv.org%'

            AND ingest_file_result.terminal_url NOT LIKE '%journals.sagepub.com%'
            AND ingest_file_result.terminal_url NOT LIKE '%pubs.acs.org%'
            AND ingest_file_result.terminal_url NOT LIKE '%ahajournals.org%'
            AND ingest_file_result.terminal_url NOT LIKE '%www.journal.csj.jp%'
            AND ingest_file_result.terminal_url NOT LIKE '%aip.scitation.org%'
            AND ingest_file_result.terminal_url NOT LIKE '%academic.oup.com%'
            AND ingest_file_result.terminal_url NOT LIKE '%tandfonline.com%'
            AND ingest_file_result.terminal_url NOT LIKE '%researchgate.net%'
            AND ingest_file_result.terminal_url NOT LIKE '%muse.jhu.edu%'
            AND ingest_file_result.terminal_url NOT LIKE '%omicsonline.org%'
            AND ingest_file_result.terminal_url NOT LIKE '%link.springer.com%'
            AND ingest_file_result.terminal_url NOT LIKE '%ieeexplore.ieee.org%'

    ) TO '/srv/sandcrawler/tasks/patch_2021-09-16_terminal_seedlist.txt';
    => 6,354,365

Then run the actual patch crawl!

## Ingest Requests for Bulk Retry (2022-01-06)

Crawl has just about completed, so running another round of bulk ingest
requests, slightly updated to allow `https://doi.org/10*` in terminal URL:

    COPY (  
        SELECT row_to_json(ingest_request.*)
        FROM ingest_request
        LEFT JOIN ingest_file_result
            ON ingest_file_result.ingest_type = ingest_request.ingest_type
            AND ingest_file_result.base_url = ingest_request.base_url
        WHERE
            ingest_request.ingest_type = 'pdf'
            AND ingest_file_result.updated <= '2022-01-01'
            AND (
                ingest_file_result.status = 'no-capture'
                OR ingest_file_result.status = 'cdx-error'
                OR ingest_file_result.status = 'wayback-error'
                OR ingest_file_result.status = 'wayback-content-error'
                OR ingest_file_result.status = 'petabox-error'
                OR ingest_file_result.status = 'spn2-cdx-lookup-failure'
                OR ingest_file_result.status = 'gateway-timeout'
            )
            AND (
                ingest_request.link_source = 'oai'
                OR (
                    ingest_request.link_source = 'doi'
                    AND (
                        ingest_request.ingest_request_source = 'fatcat-ingest'
                        OR ingest_request.ingest_request_source = 'fatcat-changelog'
                    )
                )
            )

            AND ingest_request.link_source_id NOT LIKE 'oai:kb.dk:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:bdr.oai.bsb-muenchen.de:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:hispana.mcu.es:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:bnf.fr:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:ukm.si:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:biodiversitylibrary.org:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:hsp.org:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:repec:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:n/a:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:quod.lib.umich.edu:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:americanae.aecid.es:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:www.irgrid.ac.cn:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:espace.library.uq.edu:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:edoc.mpg.de:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:bibliotecadigital.jcyl.es:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:repository.erciyes.edu.tr:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:krm.or.kr:%'
            AND ingest_request.link_source_id NOT LIKE 'oai:hypotheses.org:%'

            AND ingest_file_result.terminal_url NOT LIKE '%mdz-nbn-resolving.de%'
            AND ingest_file_result.terminal_url NOT LIKE '%edoc.mpg.de%'
            AND ingest_file_result.terminal_url NOT LIKE '%doaj.org%'
            AND ingest_file_result.terminal_url NOT LIKE '%orcid.org%'
            AND ingest_file_result.terminal_url NOT LIKE '%gateway.isiknowledge.com%'
            AND ingest_file_result.terminal_url NOT LIKE '%europmc.org%'
            AND ingest_file_result.terminal_url NOT LIKE '%arxiv.org%'
            -- AND ingest_file_result.terminal_url NOT LIKE 'https://doi.org/10.%'

            AND ingest_file_result.terminal_url NOT LIKE '%journals.sagepub.com%'
            AND ingest_file_result.terminal_url NOT LIKE '%pubs.acs.org%'
            AND ingest_file_result.terminal_url NOT LIKE '%ahajournals.org%'
            AND ingest_file_result.terminal_url NOT LIKE '%www.journal.csj.jp%'
            AND ingest_file_result.terminal_url NOT LIKE '%aip.scitation.org%'
            AND ingest_file_result.terminal_url NOT LIKE '%academic.oup.com%'
            AND ingest_file_result.terminal_url NOT LIKE '%tandfonline.com%'
            AND ingest_file_result.terminal_url NOT LIKE '%researchgate.net%'
            AND ingest_file_result.terminal_url NOT LIKE '%muse.jhu.edu%'
            AND ingest_file_result.terminal_url NOT LIKE '%omicsonline.org%'
            AND ingest_file_result.terminal_url NOT LIKE '%link.springer.com%'
            AND ingest_file_result.terminal_url NOT LIKE '%ieeexplore.ieee.org%'

            AND ingest_file_result.terminal_url NOT LIKE '%zenodo.org%'
            AND ingest_file_result.terminal_url NOT LIKE '%t2r2.star.titech.ac.jp%'
            AND ingest_file_result.terminal_url NOT LIKE '%www.google.com%'
            AND ingest_file_result.terminal_url NOT LIKE '%figshare.com%'
            AND ingest_file_result.terminal_url NOT LIKE '%springernature.figshare.com%'
    ) TO '/srv/sandcrawler/tasks/patch_ingest_request_2022-01-06.rows.json';
    => 4,488,193

    ./scripts/ingestrequest_row2json.py /srv/sandcrawler/tasks/patch_ingest_request_2022-01-06.rows.json | pv -l | shuf > /srv/sandcrawler/tasks/patch_ingest_request_2022-01-06.ingest_request.json
    => DONE

    cat /srv/sandcrawler/tasks/patch_ingest_request_2022-01-06.ingest_request.json | rg -v "\\\\" | jq . -c | kafkacat -P -b wbgrp-svc263.us.archive.org -t sandcrawler-prod.ingest-file-requests-bulk -p -1
    => TIMEDOUT
    => (probably due to re-assignment)
    => TODO: try again

## Stats Again (just OAI-PMH)

OAI-PMH query:

    SELECT ingest_file_result.status, COUNT(*)
    FROM ingest_request
    LEFT JOIN ingest_file_result
        ON ingest_file_result.ingest_type = ingest_request.ingest_type
        AND ingest_file_result.base_url = ingest_request.base_url
    WHERE 
        ingest_request.ingest_type = 'pdf'
        AND ingest_request.link_source = 'oai'
        AND ingest_request.link_source_id NOT LIKE 'oai:kb.dk:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:bdr.oai.bsb-muenchen.de:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:hispana.mcu.es:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:bnf.fr:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:ukm.si:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:biodiversitylibrary.org:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:hsp.org:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:repec:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:n/a:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:quod.lib.umich.edu:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:americanae.aecid.es:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:www.irgrid.ac.cn:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:espace.library.uq.edu:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:edoc.mpg.de:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:bibliotecadigital.jcyl.es:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:repository.erciyes.edu.tr:%'
        AND ingest_request.link_source_id NOT LIKE 'oai:krm.or.kr:%'
        AND ingest_request.base_url NOT LIKE '%www.kb.dk%'
        AND ingest_request.base_url NOT LIKE '%kb-images.kb.dk%'
        AND ingest_request.base_url NOT LIKE '%mdz-nbn-resolving.de%'
        AND ingest_request.base_url NOT LIKE '%aggr.ukm.um.si%'
        AND ingest_request.base_url NOT LIKE '%edoc.mpg.de%'
        AND ingest_request.base_url NOT LIKE '%doaj.org%'
        AND ingest_request.base_url NOT LIKE '%orcid.org%'
        AND ingest_request.base_url NOT LIKE '%gateway.isiknowledge.com%'
        AND ingest_request.link_source_id NOT LIKE 'oai:hypotheses.org:%'
    GROUP BY status
    ORDER BY COUNT DESC
    LIMIT 20;

On 2022-02-08:

            status         |  count
    -----------------------+----------
     success               | 13505143
     no-pdf-link           |  8741007
     no-capture            |  4429986
     redirect-loop         |  1566611
     terminal-bad-status   |   816162
     link-loop             |   459006
     wrong-mimetype        |   448983
     null-body             |    71871
     cdx-error             |    19055
                           |    15275
     petabox-error         |    11713
     blocked-cookie        |    11664
     wayback-error         |     8745
     skip-url-blocklist    |     7828
     max-hops-exceeded     |     2031
     wayback-content-error |      338
     body-too-large        |      280
     spn2-error:job-failed |      191
     bad-redirect          |      134
     redirects-exceeded    |      120
    (20 rows)