-
Notifications
You must be signed in to change notification settings - Fork 16
/
recent_docs_updated.sql
48 lines (46 loc) · 1.7 KB
/
recent_docs_updated.sql
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
# File: recent_docs_updated.sql
# Desc: Find papers with metadata/author updates during the previous hour.
# Based on: arxiv-bin/notify_search.pl
# Running: see arxiv-bin/dotfiles/nexus.crontab
#
SELECT am.paper_id
FROM arXiv_paper_owners apo,
arXiv_metadata am
WHERE apo.document_id = am.document_id
AND apo.valid = 1
AND apo.flag_author = 1
AND apo.flag_auto = 0
AND apo.date BETWEEN UNIX_TIMESTAMP(DATE_SUB(DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"), INTERVAL 1 HOUR))
AND UNIX_TIMESTAMP(DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))
UNION
SELECT am.paper_id
FROM arXiv_paper_owners apo,
arXiv_metadata am,
arXiv_author_ids aai
WHERE apo.document_id = am.document_id
AND apo.user_id = aai.user_id
AND apo.valid = 1
AND apo.flag_author = 1
AND apo.flag_auto = 0
AND aai.updated BETWEEN DATE_SUB(DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"), INTERVAL 1 HOUR)
AND DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00")
UNION
SELECT am.paper_id
FROM arXiv_paper_owners apo,
arXiv_metadata am,
arXiv_orcid_ids aoi
WHERE apo.document_id = am.document_id
AND apo.user_id = aoi.user_id
AND apo.valid = 1
AND apo.flag_author = 1
AND apo.flag_auto = 0
AND aoi.updated BETWEEN DATE_SUB(DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"), INTERVAL 1 HOUR)
AND DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00")
UNION
SELECT am.paper_id
FROM arXiv_metadata am
WHERE 1=1
AND am.modtime BETWEEN UNIX_TIMESTAMP(DATE_SUB(DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"), INTERVAL 1 HOUR))
AND UNIX_TIMESTAMP(DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))
ORDER BY 1 desc
;