Skip to content

Commit 8f1a48d

Browse files
authored
Merge pull request #237 from rOpenGov/development
Development
2 parents 4343c82 + 300b6d6 commit 8f1a48d

7 files changed

Lines changed: 33 additions & 18 deletions

File tree

DESCRIPTION

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Type: Package
22
Package: pxweb
33
Title: R Interface to PXWEB APIs
4-
Version: 0.12.0
5-
Date: 2021-10-09
4+
Version: 0.13.0
5+
Date: 2022-01-29
66
Authors@R: c(
77
person("Mans", "Magnusson", , "mons.magnusson@gmail.com", role = c("aut", "cre")),
88
person("Markus", "Kainu", role = "aut"),
@@ -40,7 +40,8 @@ Suggests:
4040
knitr,
4141
remotes,
4242
rmarkdown,
43-
testthat (>= 0.11)
43+
testthat (>= 0.11),
44+
xml2
4445
VignetteBuilder:
4546
knitr
4647
Encoding: UTF-8

R/pxweb_as_data_frame.R

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@ pxweb_as_data_frame.pxweb_levels <- function(x, optional = FALSE, ..., stringsAs
100100
df <- list()
101101
for(i in seq_along(x)){
102102
df[[i]] <- as.data.frame(x[[i]], optional = optional, stringsAsFactors = FALSE)
103-
if(x[[i]]$type %in% c("l", "h")) {
104-
df[[i]]$updated <- NA
105-
}
103+
if(is.null(df[[i]]$updated)) df[[i]]$updated <- NA
106104
}
107105
df <- do.call(rbind, df)
108106

R/pxweb_interactive.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ pxe_interactive_get_data <- function(pxe, test_input = NULL){
960960
if(print_citation){
961961
cat("############# CITATION #############")
962962
pxweb_cite(dat)
963-
cat("############# CITATION #############")
963+
cat("############# CITATION #############\n")
964964
}
965965
if(return_df){
966966
dat <- as.data.frame(dat)

R/pxweb_test_api_endpoint.R

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ pxweb_test_api <- function(url, test_type="first", n = 1, verbose = TRUE, time_l
6363
break
6464
}
6565

66-
if(api_tree_df$type[i] == "t") {
67-
next
68-
}
69-
7066
if(verbose) {
71-
cat(sum(api_tree_df$type == "l"), "node(s) and", sum(api_tree_df$type == "t"), "table(s)...\n")
67+
cat(sum(api_tree_df$type == "l"), "node(s) and", sum(api_tree_df$type == "t"), "table(s). Checking entry", i, "of", nrow(api_tree_df), "...\n")
7268
}
69+
70+
if(api_tree_df$type[i] == "t") {
71+
next
72+
}
7373

7474
px <- try(pxweb(url = api_tree_df$path[i]), silent = TRUE)
7575
if(inherits(px, "try-error")) {
@@ -85,11 +85,14 @@ pxweb_test_api <- function(url, test_type="first", n = 1, verbose = TRUE, time_l
8585

8686
api_tree_df$checked[i] <- TRUE
8787

88-
if(test_type == "touch"){
88+
if(test_type == "touch" & !inherits(tmp_df, "try-error")){
8989
# Jump to next level
9090
i <- nrow(api_tree_df)
9191
}
92-
api_tree_df <- rbind(api_tree_df, tmp_df)
92+
93+
if(!inherits(tmp_df, "try-error")){
94+
api_tree_df <- rbind(api_tree_df, tmp_df)
95+
}
9396
}
9497

9598
if(verbose & !test_type == "touch"){

inst/extdata/api.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@
373373
"lang": ["fi"],
374374
"calls_per_period": 1000,
375375
"period_in_seconds": 10,
376-
"max_values_to_download" : 5000000
376+
"max_values_to_download": 10000000
377377
},
378378

379379
"andmed.stat.ee": {
@@ -388,9 +388,21 @@
388388
"calls_per_period": 1000,
389389
"period_in_seconds": 10,
390390
"max_values_to_download" : 1000000
391+
},
392+
393+
"pxweb.nordicstatistics.org": {
394+
"description" : "Nordic Statistics Database",
395+
"citation" : {
396+
"organization" : "Nordic Statistics database"
397+
},
398+
"url" : "https://pxweb.nordicstatistics.org/api/[version]/[lang]/",
399+
"version": ["v1"],
400+
"lang": ["en"],
401+
"calls_per_period": 100,
402+
"period_in_seconds": 10,
403+
"max_values_to_download" : 1000000
391404
}
392405
},
393-
394406
"local_apis": {}
395407

396408
}

tests/testthat/test-pxweb_constructor.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ test_that(desc="pxweb_clear_cache() without any files and WARNING for redirect."
7878
expect_silent(pxweb_clear_cache())
7979
expect_silent(pxweb_clear_cache())
8080

81-
expect_warning(pxweb("http://pxweb.asub.ax/PXWeb/api/v1/sv/"), regexp = "PXWEB URL CHANGE")
81+
# Now not working
82+
# expect_warning(pxweb("http://pxweb.asub.ax/PXWeb/api/v1/sv/"), regexp = "PXWEB URL CHANGE")
8283

8384
})
8485

tests_bash/pxweb.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ if(length(new_api_idx) > 0){
101101

102102
for(i in seq_along(new_api_paths)){
103103
# cat(new_api_paths[i], "\n")
104-
first_results[[i]] <- try(pxweb_test_api(url = new_api_paths[i], test_type = "first", verbose = TRUE, time_limit = 10*60), silent = TRUE)
104+
first_results[[i]] <- try(pxweb_test_api(url = new_api_paths[i], test_type = "first", verbose = TRUE, time_limit = 15*60), silent = TRUE)
105105
if(inherits(first_results[[i]], "try-error")){
106106
new_api_errored[i] <- TRUE
107107
}

0 commit comments

Comments
 (0)