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

updated base/db #2758 #2774

Merged
merged 25 commits into from
Mar 8, 2021
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions base/db/R/clone_pft.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
##'
##' Creates a new pft that is a duplicate of an existing pft,
##' including relationships with priors, species, and cultivars (if any) of the existing pft.
##' This function mimics the 'clone pft' button in the PFTs record view page in the
##' BETYdb web interface for PFTs that aggregate >=1 species, but adds the ability to
##' This function mimics the 'clone pft' button in the PFTs record view page in the
##' BETYdb web interface for PFTs that aggregate >=1 species, but adds the ability to
##' clone the cultivar associations.
##'
##' @param parent.pft.name name of PFT to duplicate
Expand Down Expand Up @@ -35,15 +35,15 @@ clone_pft <- function(parent.pft.name,
on.exit(db.close(con), add = TRUE)

parent.pft <- (dplyr::tbl(con, "pfts")
%>% dplyr::filter(name == !!parent.pft.name)
%>% dplyr::filter(.data$name == !!parent.pft.name)
%>% dplyr::collect())

if (nrow(parent.pft) == 0) {
PEcAn.logger::logger.severe("No existing PFT named '", parent.pft.name, "' found in database")
}

new.pft <- (parent.pft
%>% dplyr::select(-id, -created_at, -updated_at)
%>% dplyr::select(-.data$id, -.data$created_at, -.data$updated_at)
%>% dplyr::mutate(
name = !!new.pft.name,
definition = !!new.pft.definition,
Expand All @@ -58,8 +58,8 @@ clone_pft <- function(parent.pft.name,
row.names = FALSE)

new.pft$id <- (dplyr::tbl(con, "pfts")
%>% dplyr::filter(name == !!new.pft.name)
%>% dplyr::pull(id))
%>% dplyr::filter(.data$name == !!new.pft.name)
%>% dplyr::pull(.data$id))


# PFT members are stored in different tables depending on pft_type.
Expand All @@ -72,7 +72,7 @@ clone_pft <- function(parent.pft.name,
member_tbl <- "pfts_species"
}
new_members <- (dplyr::tbl(con, member_tbl)
%>% dplyr::filter(pft_id == !!parent.pft$id)
%>% dplyr::filter(.data$pft_id == !!parent.pft$id)
%>% dplyr::mutate(pft_id = !!new.pft$id)
%>% dplyr::distinct()
%>% dplyr::collect())
Expand All @@ -87,7 +87,7 @@ clone_pft <- function(parent.pft.name,
}

new_priors <- (dplyr::tbl(con, "pfts_priors")
%>% dplyr::filter(pft_id == !!parent.pft$id)
%>% dplyr::filter(.data$pft_id == !!parent.pft$id)
%>% dplyr::mutate(pft_id = !!new.pft$id)
%>% dplyr::distinct()
%>% dplyr::collect())
Expand Down