Skip to content

Commit 7043e64

Browse files
committed
introduce crossref rate limit
1 parent d8e87bf commit 7043e64

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

server/preprocessing/other-scripts/metrics.R

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,18 @@ add_citations <- function(metadata) {
9696

9797
cc <- tryCatch(
9898
{
99-
cr_citation_count(doi = valid_dois, async = TRUE)
99+
cc_list <- list()
100+
for (doi in valid_dois) {
101+
tryCatch({
102+
count <- cr_citation_count(doi = doi)
103+
cc_list <- append(cc_list, list(count))
104+
}, error = function(err) {
105+
mlog$debug(gsub("[\r\n]", "", paste(err, doi, sep = " ")))
106+
cc_list <- append(cc_list, list(list(doi = doi, count = NA)))
107+
})
108+
Sys.sleep(0.1) # to avoid hitting rate limits
109+
}
110+
cc <- do.call(rbind.fill, cc_list)
100111
},
101112
error = function(err) {
102113
mlog$debug(gsub("[\r\n]", "", paste(err, doi, sep = " ")))

0 commit comments

Comments
 (0)