Skip to content

Commit ceb4722

Browse files
committed
Fixes #115 Incorrect download URL for getQuantityTable()
1 parent a7b45ae commit ceb4722

4 files changed

Lines changed: 22 additions & 3 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Package: activityinfo
22
Type: Package
33
Title: R interface to ActivityInfo.org, an information management software for
44
humanitarian and development operations.
5-
Version: 4.35
5+
Version: 4.35.1
66
Date: 2023-05-25
77
Authors@R: c(
88
person("Alex", "Bertram", email = "alex@bedatadriven.com",

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2+
## [4.35.1]
3+
- Fix for `getQuantityTable()` (#115)
4+
15
## [4.35]
26
- addForm() now respects folderId argument (#93)
37
- Add "bulk_delete", "manage_translations", and "reviewer_only" arguments to permissions (#91)

R/extractLong.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#' @param folderId (optional) the id of the folder or form to include. If omitted, the whole database will be included in the export.
77
#' @param includeBlanks if TRUE, the export will include a row for quantity fields with blank values. Default is FALSE.
88
#' @return a single data.frame with quantity values in rows, and dimensions in columns.
9-
#' @importFrom httr GET write_disk
9+
#' @importFrom httr GET write_disk modify_url
1010
#' @importFrom utils read.table
1111
#' @export
1212
getQuantityTable <- function(databaseId = NA, folderId, includeBlanks = FALSE) {
@@ -28,7 +28,7 @@ getQuantityTable <- function(databaseId = NA, folderId, includeBlanks = FALSE) {
2828
))
2929

3030
tempFile <- tempfile()
31-
downloadUrl <- paste(activityInfoRootUrl(), status$result$downloadUrl, sep="/")
31+
downloadUrl <- modify_url(activityInfoRootUrl(), path=status$result$downloadUrl)
3232

3333
GET(downloadUrl, write_disk(tempFile, overwrite=TRUE), activityInfoAuthentication())
3434

tests/testthat/test-export.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
testthat::test_that("getQuantityTable() works", {
2+
dbTest <- addDatabase("Reporting DB")
3+
form <- addForm(formSchema(
4+
dbTest$databaseId,
5+
label = "Activities",
6+
elements = list(textFieldSchema("Province", code = "PROVINCE", key = TRUE),
7+
quantityFieldSchema("Nb of families", code = "FAM"),
8+
quantityFieldSchema("Nb of clinics", code = "CLINICS"))))
9+
10+
addRecord(formId = form$id, fieldValues = list(PROVINCE = "North", FAM = 1012, CLINICS = 5))
11+
addRecord(formId = form$id, fieldValues = list(PROVINCE = "South", FAM = 4445, CLINICS = 13))
12+
13+
quantityTable <- getQuantityTable(databaseId = dbTest$databaseId)
14+
assertthat::assert_that(nrow(quantityTable) == 4)
15+
})

0 commit comments

Comments
 (0)