Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update list_survey() with Zenodo API updates #96

Merged
merged 2 commits into from
Oct 18, 2023
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
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
* [Cyclomatic complexity](https://en.wikipedia.org/wiki/Cyclomatic_complexity) of `download_survey()` has been reduced by externalising the `find_common_prefix()` function and failing early instead of relying on unnecessary if/else sequences
* More generous filename checks now pass files named e.g. "..._participants_common..." an not only "...participant_common..."
* The package now sets a custom user agent when downloading survey data (#82).
* A problem was fixed where attempted joins of files could lead to blowing up memeory use (#75).
* A problem was fixed where attempted joins of files could lead to blowing up memory use (#75).
* A problem was fixed where the updated Zenodo API caused downloading to fail (#91).
* A problem was fixed where the updated Zenodo API caused listing surveys to fail (#96).

# socialmixr 0.2.0

Expand Down
8 changes: 6 additions & 2 deletions R/lists.r
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@ list_surveys <- function() {
))
## find common DOI for different versions, i.e. the "relation" that is a DOI
relations <- grep("^relation(\\.|$)", colnames(record_list), value = TRUE)
DOIs <- apply(record_list, 1, function(x) grep("^doi:.*zenodo", x[relations], value = TRUE))
DOIs <- apply(
record_list, 1, function(x) {
grep("^https://doi.org/.*zenodo", x[relations], value = TRUE)
}
)
record_list <- record_list[, common_doi := DOIs]
record_list <- record_list[, url := sub("doi:", "https://doi.org/", common_doi, fixed = TRUE)]
## get number within version DOI, this is expected to be ascending by version
record_list <-
record_list[, doi.nb := as.integer(sub("^.*zenodo\\.", "", identifier.1))]
record_list[, doi.nb := as.integer(sub("^.*zenodo\\.org:", "", identifier.1))]
## save date at which first entered
record_list <- record_list[, date := min(date), by = common_doi]
## order by DOI number and extract newest version
Expand Down