Skip to content

Commit

Permalink
Merge pull request #102 from data-mermaid/release-1.1.2
Browse files Browse the repository at this point in the history
Release 1.1.2
  • Loading branch information
sharlagelfand authored Sep 25, 2024
2 parents bdef576 + 88018b9 commit 644e112
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: mermaidr
Title: Interface to the 'MERMAID' API
Version: 1.1.1
Version: 1.1.2
Authors@R:
c(person(given = "Sharla",
family = "Gelfand",
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# mermaidr 1.1.2

* Add fields `management_est_year`, `management_size`, `management_parties`, `management_compliance`, `management_rules` to `mermaid_get_summary_sampleevents()`
* Handle users without projects in `mermaid_get_me()`

# mermaidr 1.1.1

* Handle timeout error in `mermaid_import_project_data()` with suggestions to batch import data by site or date.
Expand Down
34 changes: 19 additions & 15 deletions R/mermaid_get.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,26 @@ get_me_response <- function(path, ua, limit, token) {
final_res <- res[c("id", "first_name", "last_name", "email")] %>%
dplyr::as_tibble()

projects <- res[["projects"]] %>%
dplyr::as_tibble()

# Recode roles
projects <- projects %>%
dplyr::mutate(role = dplyr::case_when(
role == 10 ~ "Read-Only",
role == 50 ~ "Collector",
role == 90 ~ "Admin"
))

projects <- projects %>%
tidyr::nest(projects = dplyr::everything())
if (length(res[["projects"]]) > 0) {
projects <- res[["projects"]] %>%
dplyr::as_tibble()

# Recode roles
projects <- projects %>%
dplyr::mutate(role = dplyr::case_when(
role == 10 ~ "Read-Only",
role == 50 ~ "Collector",
role == 90 ~ "Admin"
))

projects <- projects %>%
tidyr::nest(projects = dplyr::everything())

final_res <- final_res %>%
dplyr::bind_cols(projects)
}

final_res %>%
dplyr::bind_cols(projects)
final_res
}

get_paginated_response <- function(path, ua, token, limit) {
Expand Down
4 changes: 3 additions & 1 deletion R/mermaid_get_summary_sampleevents.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ mermaid_get_summary_sampleevents <- function(limit = NULL) {
unpack_protocols(res)
}

summary_sampleevents_columns <- c("project_id", "project", "tags", "country", "site_id", "site", "latitude", "longitude", "reef_type", "reef_zone", "reef_exposure", "management_id", "management", "sample_date", "data_policy_beltfish", "data_policy_benthiclit", "data_policy_benthicpit", "data_policy_benthicpqt", "data_policy_habitatcomplexity", "data_policy_bleachingqc", "project_notes", "site_notes", "management_notes", "contact_link", "protocols")
summary_sampleevents_columns <- c(
"project_id", "project", "tags", "country", "site_id", "site", "latitude", "longitude", "reef_type", "reef_zone", "reef_exposure", "management_id", "management", "management_est_year", "management_size", "management_parties", "management_compliance", "management_rules", "sample_date", "data_policy_beltfish", "data_policy_benthiclit", "data_policy_benthicpit", "data_policy_benthicpqt", "data_policy_habitatcomplexity", "data_policy_bleachingqc", "project_notes", "site_notes", "management_notes", "contact_link", "protocols"
)

unpack_protocols <- function(x) {
protocols_cols <- names(x[["protocols"]])
Expand Down

0 comments on commit 644e112

Please sign in to comment.