Skip to content

Commit 15df8ad

Browse files
committed
robustify metrics retrieval against missing data
1 parent 1b264cc commit 15df8ad

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
@@ -95,7 +95,18 @@ add_citations <- function(metadata) {
9595

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

0 commit comments

Comments
 (0)