Skip to content

Commit

Permalink
Merge pull request #125 from bedatadriven/fix-124
Browse files Browse the repository at this point in the history
Fix #124: Correct handling of imports with serial numbers
  • Loading branch information
akbertram authored Jul 1, 2024
2 parents be655fa + 62eedce commit 2f6ffca
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 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.36
Date: 2023-05-25
Version: 4.36.1
Date: 2023-07-01
Authors@R: c(
person("Alex", "Bertram", email = "[email protected]",
role = c("aut", "cre")),
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [4.36.1]
- Fix for `importRecords()` when the form has a serial number (#124)

## [4.36]
- API tokens are now stored per root URL of the server. The token will need to be added again using activityInfoToken(token). The location of the token file has changed from "~/.activityinfo.credentials" to "~/.activityinfo.server.credentials" to avoid accidentally overwriting and losing the old tokens. (#101)
- Column name de-duplication in getRecords() (#118)
Expand Down
5 changes: 4 additions & 1 deletion R/import.R
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ matchRecordIdsByKey <- function(schema, data, fieldIds, fieldValues) {
keys <- which(fieldIds %in% keyFieldIds)

provided <- as.data.frame(fieldValues[keys])
if(ncol(provided) != length(keyFieldIds)) {
stop("One or more key fields are missing")
}
names(provided) <- sprintf("k%d", seq_along(keyFieldIds))

# Check that our input does not include duplicates according to the key
Expand All @@ -316,7 +319,7 @@ matchRecordIdsByKey <- function(schema, data, fieldIds, fieldValues) {

findKeyFieldIds <- function(schema) {
fieldIds <- sapply(schema$elements, function(e) e$id)
keys <- sapply(schema$elements, function(e) identical(e$key, TRUE))
keys <- sapply(schema$elements, function(e) identical(e$key, TRUE) && e$type != "serial")

return(fieldIds[keys])
}
Expand Down

0 comments on commit 2f6ffca

Please sign in to comment.