Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions R/bcdc_search.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ bcdc_search_facets <- function(facet = c("license_id", "download_audience",

cli <- bcdc_catalogue_client("action/package_search")

r <- cli$get(query = list(facet.field = query, rows = 0))
r <- cli$get(query = list(facet.field = query, rows = 0, facet.limit = 1000))
r$raise_for_status()

res <- jsonlite::fromJSON(r$parse("UTF-8"))
Expand Down Expand Up @@ -80,9 +80,9 @@ bcdc_list_groups <- function() bcdc_search_facets("groups")
bcdc_list_group_records <- function(group) {
if(!has_internet()) stop("No access to internet", call. = FALSE) # nocov

cli <- bcdc_catalogue_client("action/group_show")
cli <- bcdc_catalogue_client("action/group_package_show")

r <- cli$get(query = list(id = group, include_datasets = 'true'))
r <- cli$get(query = list(id = group, limit = 1000))

if (r$status_code == 404){
stop("404: URL not found - you may have specified an invalid group?", call. = FALSE)
Expand All @@ -93,7 +93,7 @@ bcdc_list_group_records <- function(group) {
res <- jsonlite::fromJSON(r$parse("UTF-8"))
stopifnot(res$success)

d <- tibble::as_tibble(res$result$packages)
d <- tibble::as_tibble(res$result)
as.bcdc_group(d, description = res$result$description)

}
Expand All @@ -120,9 +120,14 @@ bcdc_list_organizations <- function() bcdc_search_facets("organization")
bcdc_list_organization_records <- function(organization) {
if(!has_internet()) stop("No access to internet", call. = FALSE) # nocov

cli <- bcdc_catalogue_client("action/organization_show")
query <- paste0("organization:", organization)

r <- cli$get(query = list(id = organization, include_datasets = 'true'))
cli <- bcdc_catalogue_client("action/package_search")

r <- cli$get(query = list(
fq = query, # filter query for the organization
rows = 1000 # number of datasets to retrieve (adjust as needed)
))

if (r$status_code == 404){
stop("404: URL not found - you may have specified an invalid organization?", call. = FALSE)
Expand All @@ -133,7 +138,7 @@ bcdc_list_organization_records <- function(organization) {
res <- jsonlite::fromJSON(r$parse("UTF-8"))
stopifnot(res$success)

d <- tibble::as_tibble(res$result$packages)
d <- tibble::as_tibble(res$result$results)
as.bcdc_organization(d, description = res$result$description)

}
Expand Down
Loading