Skip to content

Commit

Permalink
epmc_search: populate the hit_count attribute even with zero results
Browse files Browse the repository at this point in the history
  • Loading branch information
arvi1000 committed Jun 12, 2024
1 parent 86ccdfc commit 2c6462d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion R/epmc_search.r
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ epmc_search <- function(query = NULL,
hits <- epmc_hits(query, synonym = synonym)
if (hits == 0) {
message("There are no results matching your query")
md <- NULL
# return an empty tibble
md <- tibble::tibble()
# populate the hit_count attribute even with zero results
attr(md, "hit_count") <- hits
} else {
limit <- as.integer(limit)
limit <- ifelse(hits <= limit, hits, limit)
Expand Down

0 comments on commit 2c6462d

Please sign in to comment.