Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Package: activityinfo
Type: Package
Title: R interface to ActivityInfo.org, an information management software for
humanitarian and development operations
Version: 4.39
Date: 2025-04-02
Version: 5.0
Date: 2026-09-25
Authors@R: c(
person("Alex", "Bertram", email = "alex@bedatadriven.com",
role = c("aut", "cre")),
Expand Down Expand Up @@ -41,7 +41,7 @@ Suggests:
ggplot2,
quanteda,
scales,
testthat (>= 3.0.0),
testthat (>= 3.1.7),
knitr,
rmarkdown,
markdown,
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,10 @@ export(migrateFieldData)
export(minimalColumnStyle)
export(monthFieldSchema)
export(multilineFieldSchema)
export(multipleReferenceFieldSchema)
export(multipleSelectFieldSchema)
export(namedElementVarList)
export(noteFieldSchema)
export(parameter)
export(permissions)
export(prettyColumnStyle)
Expand Down
28 changes: 28 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
## [5.0]
Potential breaking changes:
- `hideFromEntry` now hides a field from data entry (previously it hid the field from the table), `hideInTable` now hides a field from the table (previously it was ignored), and `reviewerOnly` now restricts a field to reviewers (previously it was ignored)
- Databases are no longer required to have an individual owner. `getDatabases()` and `getBillingAccountDatabases()` now return `NA` for the owner columns (`ownerId`, `ownerName`, `ownerEmail`) of databases without an owner, rather than failing
- User fields are now identified correctly when reading form schemas, so `getRecords()` includes them as columns with `minimalColumnStyle()` (previously they were left out)

New features:
- New `noteFieldSchema()` for note fields, which display guidance during data entry but do not capture a value. Notes are not included as columns in `getRecords()`
- New `multipleReferenceFieldSchema()` for fields that reference one or more records in another form. `importRecords()` accepts comma-separated record ids for these fields
- New `requiredRule` and `validationMessage` arguments for form field schemas, to limit when a required field is required and to show a custom message when validation fails
- `as.data.frame()` of a form schema now includes the `requiredCondition` and `validationMessage` columns
- Form field schemas from `getFormSchema()` now always include `dataEntryVisible`, like `tableVisible`

Fixes:
- `getDatabases()` and `getBillingAccountDatabases()` no longer fail when the server returns a null description, as self-managed servers do
- The `lastRecordUpdate` column of `getBillingAccountDatabases()` is now always character, including when no database has records
- `queryAuditLog()` no longer fails on events with none or several resource types; these are combined into a single comma-separated value in the `resourceTypes` column

Testing:
- Tests with fixed server responses for databases with and without an owner, and for the fixes above
- API tests now authenticate with an API token rather than basic password authentication
- Tests updated for testthat 3.3 and to not depend on the versions of pandoc and rmarkdown
- Tests can be run against the self-managed server

## [4.39]
- `getDatabaseBillingAccount()` now includes `parentBillingAccountId` and handles billing accounts without a parent (#150)
- Fixed `getDatabaseBillingAccount()` for billing accounts with no addons (#151, #152)

## [4.38]
- New vignettes on grant-based roles, advanced user management (bulk actions), and advanced role use-cases (#122, #133)
- Improved metadata on getRecords() to include last time modified (#26, #39)
Expand Down
5 changes: 5 additions & 0 deletions R/audit.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ queryAuditLog <- function(databaseId, before = Sys.time(), after, resourceId = N
event$user.email <- NA
}
event$user <- NULL
# Fields such as resourceTypes may have none or several values: combine
# them so that each event is a single row
event <- lapply(event, function(x) {
if (length(x) == 1) x else if (length(x) == 0) NA else paste(unlist(x), collapse = ",")
})
as.data.frame(event, stringsAsFactors = FALSE)
}))

Expand Down
14 changes: 5 additions & 9 deletions R/billingInfo.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,15 @@ getBillingAccountDatabases <- function(billingAccountId, asDataFrame = TRUE) {
billingDatabases <- tibble::tibble(
databaseId = unlist(lapply(billingDatabases, function(x) {x$databaseId})),
label = unlist(lapply(billingDatabases, function(x) {x$label})),
description = unlist(lapply(billingDatabases, function(x) { if(nzchar(x$description)) x$description else NA_character_ })),
ownerId = unlist(lapply(billingDatabases, function(x) {x$owner[["id"]]})),
ownerName = unlist(lapply(billingDatabases, function(x) {x$owner[["name"]]})),
ownerEmail = unlist(lapply(billingDatabases, function(x) {x$owner[["email"]]})),
description = vapply(billingDatabases, function(x) {emptyToNA(x$description)}, character(1)),
ownerId = vapply(billingDatabases, function(x) {charOrNA(x$owner[["id"]])}, character(1)),
ownerName = vapply(billingDatabases, function(x) {charOrNA(x$owner[["name"]])}, character(1)),
ownerEmail = vapply(billingDatabases, function(x) {charOrNA(x$owner[["email"]])}, character(1)),
formCount = unlist(lapply(billingDatabases, function(x) {x$formCount})),
userCount = unlist(lapply(billingDatabases, function(x) {x$userCount})),
basicUserCount = unlist(lapply(billingDatabases, function(x) {x$basicUserCount})),
recordCount = unlist(lapply(billingDatabases, function(x) {x$recordCount})),
lastRecordUpdate = unlist(lapply(billingDatabases, function(x) {
if(is.null(x$lastRecordUpdate))
{NA} else
{x$lastRecordUpdate}
})),
lastRecordUpdate = vapply(billingDatabases, function(x) {charOrNA(x$lastRecordUpdate)}, character(1)),
billingAccountId = unlist(lapply(billingDatabases, function(x) {x$billingAccountId})),
suspended = unlist(lapply(billingDatabases, function(x) {x$suspended})),
publishedTemplate = unlist(lapply(billingDatabases, function(x) {x$publishedTemplate}))
Expand Down
17 changes: 14 additions & 3 deletions R/databases.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ getDatabases <- function(asDataFrame = TRUE) {
return(databasesListToTibble(databases))
} else if (asDataFrame == FALSE) {
return(lapply(databases, function(x) {
x$ownerId <- as.character(x$ownerId)
x$ownerId <- charOrNA(x$ownerId)
x$billingAccountId <- as.character(x$billingAccountId)
x
}))
Expand All @@ -24,14 +24,25 @@ databasesListToTibble <- function(databases) {
dbDF <- dplyr::tibble(
databaseId = unlist(lapply(databases, function(x) {x$databaseId})),
label = unlist(lapply(databases, function(x) {x$label})),
description = unlist(lapply(databases, function(x) { if(nzchar(x$description)) x$description else NA_character_ })),
ownerId = as.character(unlist(lapply(databases, function(x) {x$ownerId}))),
description = vapply(databases, function(x) {emptyToNA(x$description)}, character(1)),
ownerId = vapply(databases, function(x) {charOrNA(x$ownerId)}, character(1)),
billingAccountId = as.character(unlist(lapply(databases, function(x) {x$billingAccountId}))),
suspended = unlist(lapply(databases, function(x) {x$suspended}))
)
return(dbDF)
}

# Databases are no longer required to have an individual owner, so
# owner fields may be null
charOrNA <- function(x) {
if (is.null(x)) NA_character_ else as.character(x)
}

# The server may return an empty or a null description
emptyToNA <- function(x) {
if (is.null(x) || !nzchar(x)) NA_character_ else as.character(x)
}

databaseUpdates <- function() {
list(
resourceUpdates = list(),
Expand Down
Loading
Loading