Skip to contents

Returns top-level and Trash counts for one library, plus per-collection counts when collection keys are supplied.

Usage

ztCensus(config, library = "user", collectionKeys = NULL)

Arguments

config

A zotConfig() object.

library

"user" or a group id.

collectionKeys

Optional named character vector: name -> key.

Value

A data.table with scope and total.

Details

Each scope is counted from the API Total-Results response header while requesting only one record. Supplying named collection keys adds one row per requested collection without downloading the library contents.

Examples

Performer <- function(config, method, path, query, body, version) {
  Total <- if (grepl("/trash", path)) "7" else "100"
  list(status = 200L, headers = list(`total-results` = Total), body = list())
}
Config <- structure(
  list(userID = "42", key = "example", apiBase = "https://example.invalid",
       performer = Performer),
  class = "zotConfig"
)
ztCensus(Config)
#>     scope total
#>    <char> <int>
#> 1:    top   100
#> 2:  trash     7