From d8cb21ef7a2c955d92b85f5f29f9fba45c95398c Mon Sep 17 00:00:00 2001 From: ross-hull Date: Fri, 14 Jun 2024 15:20:11 +0000 Subject: [PATCH 1/4] Style code (GHA) --- R/get_dataset_additional_info.R | 17 ++++++++--------- R/list_datasets.R | 20 ++++++++------------ 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/R/get_dataset_additional_info.R b/R/get_dataset_additional_info.R index 22c356e..bdd7741 100644 --- a/R/get_dataset_additional_info.R +++ b/R/get_dataset_additional_info.R @@ -4,25 +4,24 @@ #' @param dataset_name #' #' @return -get_datasets_additional_info <- function(dataset_name){ +get_datasets_additional_info <- function(dataset_name) { query <- list("id" = dataset_name) content <- phs_GET("package_show", query) amount_of_resources <- content$result$resources %>% length() - last_resource_created_date <- purrr::map_chr(content$result$resources, ~.$created) + last_resource_created_date <- purrr::map_chr(content$result$resources, ~ .$created) - last_resource_modified_date <- purrr::map_chr(content$result$resources, ~.$last_modified) + last_resource_modified_date <- purrr::map_chr(content$result$resources, ~ .$last_modified) most_recent_resource_date <- max(last_resource_modified_date, last_resource_created_date) - return_value <- list("name" = dataset_name, - "amount_of_resources" = amount_of_resources, - "most_recent_resource_date" = most_recent_resource_date) + return_value <- list( + "name" = dataset_name, + "amount_of_resources" = amount_of_resources, + "most_recent_resource_date" = most_recent_resource_date + ) return(return_value) - } - - diff --git a/R/list_datasets.R b/R/list_datasets.R index 899cdb8..8963f45 100644 --- a/R/list_datasets.R +++ b/R/list_datasets.R @@ -13,25 +13,21 @@ #' head(list_datasets(include_additional_info = TRUE)) list_datasets <- function(include_additional_info = FALSE) { data_sets <- phs_GET("package_list", "")$result - if(!include_additional_info){ + if (!include_additional_info) { data_sets <- tibble::tibble("name" = unlist(data_sets)) - return(data_sets)} - else{ + return(data_sets) + } else { datasets <- purrr::map(data_sets, get_datasets_additional_info) - return_value <- tibble::tibble(name = purrr::map_chr(datasets, ~.$name), - most_recent_resource_date = purrr::map_chr(datasets, ~.$most_recent_resource_date), - amount_of_resources = purrr::map_int(datasets, ~.$amount_of_resources)) %>% + return_value <- tibble::tibble( + name = purrr::map_chr(datasets, ~ .$name), + most_recent_resource_date = purrr::map_chr(datasets, ~ .$most_recent_resource_date), + amount_of_resources = purrr::map_int(datasets, ~ .$amount_of_resources) + ) %>% dplyr::mutate(most_recent_resource_date = as.POSIXct(most_recent_resource_date, format = "%FT%X", tz = "UTC")) return(return_value) } } - - - - - - From 3c85f3b6a131980af32a1c4fc187693732574181 Mon Sep 17 00:00:00 2001 From: James McMahon Date: Wed, 19 Jun 2024 15:23:50 +0100 Subject: [PATCH 2/4] Update NEWS and version (#34) * Increment the version Incremented to a 'dev' version. `usethis::use_version()` can be used to do this. When used again to 0.2.0 for example, it will replace the dev heading in the NEWS. * Add NEWS items for changes since the last release I've only included user-facing/relevant changes. --- DESCRIPTION | 2 +- NEWS.md | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 88d82dc..f328f7b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: phsopendata Title: Extract Open Data from opendata.nhs.scot -Version: 0.1.0 +Version: 0.1.0.9000 Authors@R: c( person("Csilla", "Scharle", , "csilla.scharle2@phs.scot", role = c("aut", "cre")), person("James", "McMahon", , "james.mcmahon@phs.scot", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 5245345..b7ce93b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,13 @@ +# phsopendata (development version) + +- `get_dataset()` and `get_resource()` gain a new parameter `include_context` +which allows adding context such as the resource ID and modified / created +dates to returned data (#24). +- The magrittr pipe (`%>%`) is now exported (#29). +- `get_dataset()` will now suggest multiple dataset names, when the dataset +you've asked for doesn't exist (i.e. there's a typo) and there are multiple +likely candidates (#28). + # phsopendata 0.1.0 (2021-07-22) - Initial package release. From bf62035aebd1a42e1cb6cdf719a4c08d40f6cdcd Mon Sep 17 00:00:00 2001 From: James McMahon Date: Wed, 19 Jun 2024 15:29:03 +0100 Subject: [PATCH 3/4] Add bullet to NEWS --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index b7ce93b..5bad634 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,6 +7,8 @@ dates to returned data (#24). - `get_dataset()` will now suggest multiple dataset names, when the dataset you've asked for doesn't exist (i.e. there's a typo) and there are multiple likely candidates (#28). +- Two new functions `list_datasets()` and `list_resources()` allow browsing +available datasets and resources (#10). # phsopendata 0.1.0 (2021-07-22) From 2ae53d9a1b162874a5d215ab94d3de4d81082a8b Mon Sep 17 00:00:00 2001 From: James McMahon Date: Wed, 19 Jun 2024 15:31:22 +0100 Subject: [PATCH 4/4] Add Ross (@ross-hull) as an package author --- DESCRIPTION | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index f328f7b..8f04ce9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -4,7 +4,8 @@ Version: 0.1.0.9000 Authors@R: c( person("Csilla", "Scharle", , "csilla.scharle2@phs.scot", role = c("aut", "cre")), person("James", "McMahon", , "james.mcmahon@phs.scot", role = "aut"), - person("David", "Aikman", , "david.aikman@phs.scot", role = "aut") + person("David", "Aikman", , "david.aikman@phs.scot", role = "aut"), + person("Ross", "Hull", , "ross.hull2@phs.scot", role = "aut") ) Description: Functions to extract and interact with data from the Scottish Health and Social Care Open Data platform.