Skip to content

Commit 894a2ce

Browse files
authored
Add script to restore correct arXiv preprint dates (#64)
* Add script to restore correct arXiv preprint dates * Auto-format python code --------- Co-authored-by: michamos <[email protected]>
1 parent 8fa20bb commit 894a2ce

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from datetime import datetime
2+
from inspirehep.curation.search_check_do import SearchCheckDo
3+
4+
5+
class RestoreArxivPreprintDate(SearchCheckDo):
6+
"""Restore the correct preprint_date which got overwritten due to an arXiv OAI-PMH bug."""
7+
8+
query = "da < 2025-06-16 and arxiv_eprints.value:* and preprint_date:2025-06-16->2025-07-01"
9+
10+
@staticmethod
11+
def check(record, logger, state):
12+
return (
13+
record.created < datetime(2025, 6, 16, 8)
14+
and record.get("preprint_date", "0") >= "2025-06-16"
15+
)
16+
17+
@staticmethod
18+
def do(record, logger, state):
19+
current_preprint_date = record["preprint_date"]
20+
for revision_id in range(2, record.revision_id):
21+
preprint_date = record.revisions[-revision_id].get("preprint_date")
22+
if preprint_date and preprint_date != current_preprint_date:
23+
record["preprint_date"] = preprint_date
24+
return
25+
logger.warning("Preprint date not modified")
26+
27+
28+
RestoreArxivPreprintDate()

0 commit comments

Comments
 (0)