diff --git a/DESCRIPTION b/DESCRIPTION index e86998e..52263ef 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: eesyapi Title: EES-y API -Version: 0.2.0 +Version: 0.2.1 Authors@R: c( person("Rich", "Bielby", , "richard.bielby@education.gov.uk", role = c("aut", "cre"), diff --git a/NAMESPACE b/NAMESPACE index 8db4dd6..4306f15 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -14,7 +14,6 @@ export(parse_api_dataset) export(parse_filter_in) export(parse_meta_filter_columns) export(parse_meta_filter_item_ids) -export(parse_meta_indicator_columns) export(parse_meta_location_ids) export(parse_meta_time_periods) export(query_dataset) diff --git a/NEWS.md b/NEWS.md index 2b3cc52..dd75304 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# eesyapi 0.2.1 + +* Updated `get_meta()` to work with new API meta output (addition of id alongside col_name and label) +* Removed redundant function: `parse_meta_filter_columns()` +* Hex logo added for documentation + # eesyapi 0.2.0 * Creating publication querying functions: diff --git a/R/get_meta.R b/R/get_meta.R index 6174ce9..d365087 100644 --- a/R/get_meta.R +++ b/R/get_meta.R @@ -145,7 +145,8 @@ parse_meta_location_ids <- function(api_meta_locations) { #' parse_meta_filter_columns() parse_meta_filter_columns <- function(api_meta_filters) { data.frame( - col_name = api_meta_filters$id, + col_id = api_meta_filters$id, + col_name = api_meta_filters$column, label = api_meta_filters$label ) } @@ -163,13 +164,13 @@ parse_meta_filter_columns <- function(api_meta_filters) { parse_meta_filter_item_ids <- function(api_meta_filters) { nfilters <- length(api_meta_filters$id) filter_items <- data.frame( - col_name = NA, + col_id = NA, item_id = NA, item_label = NA, isAggregate = NA ) filter_items <- filter_items |> - dplyr::filter(!is.na(filter_items$col_name)) + dplyr::filter(!is.na(filter_items$col_id)) for (i in 1:nfilters) { filter_items_i <- as.data.frame( api_meta_filters$options[i] @@ -178,7 +179,7 @@ parse_meta_filter_item_ids <- function(api_meta_filters) { item_id = "id", item_label = "label" ) |> - dplyr::mutate(col_name = api_meta_filters$id[i]) + dplyr::mutate(col_id = api_meta_filters$id[i]) if (!("isAggregate" %in% names(filter_items_i))) { filter_items_i <- filter_items_i |> dplyr::mutate(isAggregate = NA) @@ -186,25 +187,8 @@ parse_meta_filter_item_ids <- function(api_meta_filters) { filter_items <- filter_items |> rbind( filter_items_i |> - dplyr::select("col_name", "item_label", "item_id", default_item = "isAggregate") + dplyr::select("col_id", "item_label", "item_id", default_item = "isAggregate") ) } return(filter_items) } - -#' Parse API meta to give the indicator columns -#' -#' @param api_meta_indicators Indicator information provided by the API output -#' -#' @return data frame containing indicator column names and labels -#' @export -#' -#' @examples -#' get_meta_response(example_id())$indicators |> -#' parse_meta_indicator_columns() -parse_meta_indicator_columns <- function(api_meta_indicators) { - data.frame( - col_name = api_meta_indicators$id, - label = api_meta_indicators$label - ) -} diff --git a/man/parse_meta_indicator_columns.Rd b/man/parse_meta_indicator_columns.Rd deleted file mode 100644 index 4812a96..0000000 --- a/man/parse_meta_indicator_columns.Rd +++ /dev/null @@ -1,21 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/get_meta.R -\name{parse_meta_indicator_columns} -\alias{parse_meta_indicator_columns} -\title{Parse API meta to give the indicator columns} -\usage{ -parse_meta_indicator_columns(api_meta_indicators) -} -\arguments{ -\item{api_meta_indicators}{Indicator information provided by the API output} -} -\value{ -data frame containing indicator column names and labels -} -\description{ -Parse API meta to give the indicator columns -} -\examples{ -get_meta_response(example_id())$indicators |> - parse_meta_indicator_columns() -} diff --git a/tests/testthat/seed_tests.R b/tests/testthat/seed_tests.R index 2cccde2..9c11d19 100644 --- a/tests/testthat/seed_tests.R +++ b/tests/testthat/seed_tests.R @@ -16,8 +16,12 @@ # Refresh all test data seed_tests <- function() { + message("Updating publication list") seed_get_publications() + message("Updating data catalogue list") seed_get_data_catalogue() + message("Updating example meta data") + seed_get_meta() } # Refresh the publication list @@ -35,3 +39,15 @@ seed_get_data_catalogue <- function() { file = "tests/testthat/testdata/example_publication_datasets.rds" ) } + +# Refresh the data sets list from the standard example publication +seed_get_meta <- function() { + saveRDS( + eesyapi::get_meta_response(eesyapi::example_id()), + file = "tests/testthat/testdata/example_meta_unparsed.rds" + ) + saveRDS( + eesyapi::get_meta(eesyapi::example_id()), + file = "tests/testthat/testdata/example_meta_parsed.rds" + ) +} diff --git a/tests/testthat/test-get_meta.R b/tests/testthat/test-get_meta.R index 0211fd5..5c4ea8f 100644 --- a/tests/testthat/test-get_meta.R +++ b/tests/testthat/test-get_meta.R @@ -66,7 +66,7 @@ test_that("Filter item ids parsing works as expected", { test_that("Indicator ids parsing works as expected", { expect_equal( readRDS("testdata/example_meta_unparsed.rds")$indicators |> - parse_meta_indicator_columns(), + parse_meta_filter_columns(), readRDS("testdata/example_meta_parsed.rds")$indicators ) }) diff --git a/tests/testthat/testdata/example_meta_parsed.rds b/tests/testthat/testdata/example_meta_parsed.rds index 06385e0..11d49b9 100644 Binary files a/tests/testthat/testdata/example_meta_parsed.rds and b/tests/testthat/testdata/example_meta_parsed.rds differ diff --git a/tests/testthat/testdata/example_meta_unparsed.rds b/tests/testthat/testdata/example_meta_unparsed.rds index fd3571f..1675282 100644 Binary files a/tests/testthat/testdata/example_meta_unparsed.rds and b/tests/testthat/testdata/example_meta_unparsed.rds differ