Skip to content

Commit

Permalink
Dev 221 - hawkinR v1.1.1 w/ Add and Update player functions (#26)
Browse files Browse the repository at this point in the history
* fixes (or removes) log suppression:  surface more useful logging to end-users by removing log suppression present in v1.1.0 and earlier
  • Loading branch information
laureng-hd authored Jul 30, 2024
1 parent badf378 commit d65adc1
Show file tree
Hide file tree
Showing 22 changed files with 123 additions and 182 deletions.
16 changes: 16 additions & 0 deletions .Rhistory
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,19 @@ pkgdown::build_site()
git add .
pkgdown::build_site()
pkgdown::build_site()
devtools::load_all(".")
devtools::load_all(".")
devtools::load_all(".")
devtools::load_all(".")
devtools::load_all(".")
devtools::load_all(".")
?packageStartupMessage
devtools::load_all(".")
devtools::load_all(".")
devtools::load_all(".")
Sys.getenv("GITHUB_PAT")
devtools::install_github("laureng-hd/hawkinR", auth_token = Sys.getenv("GITHUB_PAT"))
devtools::install_github("HawkinDynamics/hawkinR", auth_token = Sys.getenv("GITHUB_PAT"))
github_token <- Sys.getenv("GITHUB_PAT")
Sys.getenv("GITHUB_PAT")
logger::log_formatter(logger::formatter_glue_or_sprintf)
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: hawkinR
Title: R package to work with data from the Hawkin Dynamics API
Version: 1.1.0
Version: 1.1.1
Authors@R:
person("Lauren", "Green", , "[email protected]", role = c("aut", "cre"))
Description: Provides simple functionality with Hawkin Dynamics API. These functions are for use with 'Hawkin Dynamics Beta API' version 1.8-beta. You must be an Hawkin Dynamics user with active integration account to utilize functions within the package. This API is designed to get data out of your Hawkin Dynamics database into your own database. It is not designed to be accessed from client applications directly. There is a limit on the amount of data that can be returned in a single request. As your database grows, it will be necessary to use the from and to parameters to limit the size of the responses. Responses that exceed the memory limit will fail.
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## hawkinR v1.1.1

* fixes (or removes) log suppression: surface more useful logging to end-users by removing log suppression present in v1.1.0 and earlier

## hawkinR v1.1.0

* Update of `get_tests()` functionality.
Expand Down
17 changes: 6 additions & 11 deletions R/create_athletes.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,11 @@

# Create Athletes -----
create_athletes <- function(athleteData) {

# 1. ----- Set Logger -----
# Log Trace
logger::log_trace(base::paste0("hawkinR -> Run: create_athletes"))

# Save the current setting
old_show_error_messages <- base::getOption("show.error.messages")
base::on.exit(base::options(show.error.messages = old_show_error_messages),
add = TRUE)

# Disable error messages
base::options(show.error.messages = FALSE)

# 2. ----- Parameter Validation -----

# Retrieve access token and expiration from environment variables
Expand All @@ -81,10 +74,11 @@ create_athletes <- function(athleteData) {
# Check for Access Token and Expiration
if (base::is.null(aToken) ||
token_exp <= base::as.numeric(base::Sys.time())) {
logger::log_error("hawkinR/create_athletes -> Access token not available or expired. Call get_access() to obtain it.")
stop("Access token not available or expired. Call get_access() to obtain it.")
} else {
# Log Debug
logger::log_debug(base::paste0("hawkinR/create_athletes -> Temporary access token expires: ", as.POSIXct(token_exp)))
logger::log_debug(base::paste0("hawkinR/create_athletes -> Temporary access token expires: ", base::as.POSIXct(token_exp)))
}

# 3. ----- Build URL Request -----
Expand Down Expand Up @@ -132,9 +126,10 @@ create_athletes <- function(athleteData) {
}

if (!base::is.null(error_message)) {
stop(logger::log_error(
logger::log_error(
base::paste0("hawkinR/create_athletes -> ", error_message)
))
)
stop(error_message)
}

# Response Table
Expand Down
13 changes: 3 additions & 10 deletions R/get_access.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,6 @@ get_access <- function(refreshToken, region = "Americas") {
# Log Trace
logger::log_trace(paste0("hawkinR -> Run: get_access"))

# Save the current setting
old_show_error_messages <- base::getOption("show.error.messages")
base::on.exit(options(show.error.messages = old_show_error_messages),
add = TRUE)

# Disable error messages
base::options(show.error.messages = FALSE)

# 2. ----- Parameter Validation -----

if (base::is.character(refreshToken)) {
Expand Down Expand Up @@ -139,9 +131,10 @@ get_access <- function(refreshToken, region = "Americas") {
}

if (!base::is.null(error_message)) {
stop(logger::log_error(paste0(
logger::log_error(paste0(
"hawkinR/get_access -> ", error_message
)))
))
stop(error_message)
}

# Response Table
Expand Down
16 changes: 5 additions & 11 deletions R/get_athletes.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,6 @@ get_athletes <- function(includeInactive = FALSE) {
# Log Trace
logger::log_trace(base::paste0("hawkinR -> Run: get_athltes"))

# Save the current setting
old_show_error_messages <- base::getOption("show.error.messages")
base::on.exit(base::options(show.error.messages = old_show_error_messages),
add = TRUE)

# Disable error messages
base::options(show.error.messages = FALSE)

# 2. ----- Parameter Validation -----

# Retrieve access token and expiration from environment variables
Expand All @@ -74,10 +66,11 @@ get_athletes <- function(includeInactive = FALSE) {
# Check for Access Token and Expiration
if (base::is.null(aToken) ||
token_exp <= base::as.numeric(base::Sys.time())) {
logger::log_error("hawkinR/get_athletes -> Access token not available or expired. Call get_access() to obtain it.")
stop("Access token not available or expired. Call get_access() to obtain it.")
} else {
# Log Debug
logger::log_debug(base::paste0("hawkinR/get_athletes -> Temporary access token expires: ", as.POSIXct(token_exp)))
logger::log_debug(base::paste0("hawkinR/get_athletes -> Temporary access token expires: ", base::as.POSIXct(token_exp)))
}

# 3. ----- Build URL Request -----
Expand Down Expand Up @@ -132,9 +125,10 @@ get_athletes <- function(includeInactive = FALSE) {
}

if (!base::is.null(error_message)) {
stop(logger::log_error(base::paste0(
logger::log_error(base::paste0(
"hawkinR/get_athletes -> ", error_message
)))
))
stop(error_message)
}

# Response Table
Expand Down
17 changes: 6 additions & 11 deletions R/get_forcetime.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@ get_forcetime <- function(testId) {
# Log Trace
logger::log_trace(base::paste0("hawkinR -> Run: get_forcetime"))

# Save the current setting
old_show_error_messages <- base::getOption("show.error.messages")
base::on.exit(base::options(show.error.messages = old_show_error_messages),
add = TRUE)

# Disable error messages
base::options(show.error.messages = FALSE)

# 2. ----- Parameter Validation -----

# Retrieve access token and expiration from environment variables
Expand All @@ -68,17 +60,19 @@ get_forcetime <- function(testId) {
# Check for Access Token and Expiration
if (base::is.null(aToken) ||
token_exp <= base::as.numeric(base::Sys.time())) {
logger::log_error("hawkinR/get_forcetime -> Access token not available or expired. Call get_access() to obtain it.")
stop("Access token not available or expired. Call get_access() to obtain it.")
} else {
# Log Debug
logger::log_debug(base::paste0("hawkinR/get_forcetime -> Temporary access token expires: ", as.POSIXct(token_exp)))
logger::log_debug(base::paste0("hawkinR/get_forcetime -> Temporary access token expires: ", base::as.POSIXct(token_exp)))
}

#-----#

# Validate Test Id Parameter
if (!base::is.character(testId)) {
base::stop(logger::log_error(base::paste0("hawkinR/get_forcetime -> Incorrect testId. Must be a character string.")))
logger::log_error(base::paste0("hawkinR/get_forcetime -> Incorrect testId. Must be a character string."))
base::stop("Incorrect testId. Must be a character string.")
}

# 2. ----- Build URL Request -----
Expand Down Expand Up @@ -120,7 +114,8 @@ get_forcetime <- function(testId) {
}

if (!base::is.null(error_message)) {
stop(logger::log_error(base::paste0("hawkinR/get_tforcetime -> ",error_message)))
logger::log_error(base::paste0("hawkinR/get_tforcetime -> ",error_message))
stop(error_message)
}

# Response Table
Expand Down
16 changes: 5 additions & 11 deletions R/get_groups.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ get_groups <- function() {
# Log Trace
logger::log_trace(base::paste0("hawkinR -> Run: get_groups"))

# Save the current setting
old_show_error_messages <- base::getOption("show.error.messages")
base::on.exit(base::options(show.error.messages = old_show_error_messages),
add = TRUE)

# Disable error messages
base::options(show.error.messages = FALSE)

# 2. ----- Parameter Validation -----

# Retrieve access token and expiration from environment variables
Expand All @@ -60,10 +52,11 @@ get_groups <- function() {
# Check for Access Token and Expiration
if (base::is.null(aToken) ||
token_exp <= base::as.numeric(base::Sys.time())) {
logger::log_error("hawkinR/get_groups -> Access token not available or expired. Call get_access() to obtain it.")
stop("Access token not available or expired. Call get_access() to obtain it.")
} else {
# Log Debug
logger::log_debug(base::paste0("hawkinR/get_groups -> Temporary access token expires: ", as.POSIXct(token_exp)))
logger::log_debug(base::paste0("hawkinR/get_groups -> Temporary access token expires: ", base::as.POSIXct(token_exp)))
}

# 3. ----- Build URL Request -----
Expand Down Expand Up @@ -103,9 +96,10 @@ get_groups <- function() {
}

if (!base::is.null(error_message)) {
stop(logger::log_error(base::paste0(
logger::log_error(base::paste0(
"hawkinR/get_teams -> ", error_message
)))
))
stop(error_message)
}

# Response Table
Expand Down
19 changes: 7 additions & 12 deletions R/get_metrics.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ get_metrics <- function(testType = "all") {
# Log Trace
logger::log_trace(base::paste0("hawkinR -> Run: get_metrics"))

# Save the current setting
old_show_error_messages <- base::getOption("show.error.messages")
base::on.exit(base::options(show.error.messages = old_show_error_messages),
add = TRUE)

# Disable error messages
base::options(show.error.messages = FALSE)

# 2. ----- Parameter Validation -----

# Retrieve access token and expiration from environment variables
Expand All @@ -70,10 +62,11 @@ get_metrics <- function(testType = "all") {
# Check for Access Token and Expiration
if (base::is.null(aToken) ||
token_exp <= base::as.numeric(base::Sys.time())) {
logger::log_error("hawkinR/get_metrics -> Access token not available or expired. Call get_access() to obtain it.")
stop("Access token not available or expired. Call get_access() to obtain it.")
} else {
# Log Debug
logger::log_debug(base::paste0("hawkinR/get_metrics -> Temporary access token expires: ", as.POSIXct(token_exp)))
logger::log_debug(base::paste0("hawkinR/get_metrics -> Temporary access token expires: ", base::as.POSIXct(token_exp)))
}

#-----#
Expand Down Expand Up @@ -125,9 +118,10 @@ get_metrics <- function(testType = "all") {
}

if (!base::is.null(error_message)) {
stop(logger::log_error(base::paste0(
logger::log_error(base::paste0(
"hawkinR/get_metrics -> ", error_message
)))
))
stop(error_message)
}

# Response Table
Expand Down Expand Up @@ -178,6 +172,7 @@ get_metrics <- function(testType = "all") {
} else {
# Filter for Test Type
tests <- dplyr::filter(x, x[[1]] == tId)
tests <- tests[[1, 3]]

# Create Data Frame and Return Output
logger::log_success(
Expand All @@ -188,7 +183,7 @@ get_metrics <- function(testType = "all") {
testType
)
)
base::return(tests[[1, 3]])
base::return(tests)
}
}
}
Expand Down
14 changes: 4 additions & 10 deletions R/get_tags.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@ get_tags <- function() {
# Log Trace
logger::log_trace(base::paste0("hawkinR -> Run: get_tags"))

# Save the current setting
old_show_error_messages <- base::getOption("show.error.messages")
base::on.exit(base::options(show.error.messages = old_show_error_messages),
add = TRUE)

# Disable error messages
base::options(show.error.messages = FALSE)

# 2. ----- Parameter Validation -----

# Retrieve access token and expiration from environment variables
Expand All @@ -61,10 +53,11 @@ get_tags <- function() {
# Check for Access Token and Expiration
if (base::is.null(aToken) ||
token_exp <= base::as.numeric(base::Sys.time())) {
logger::log_error("hawkinR/get_tags -> Access token not available or expired. Call get_access() to obtain it.")
stop("Access token not available or expired. Call get_access() to obtain it.")
} else {
# Log Debug
logger::log_debug(base::paste0("hawkinR/get_tags -> Temporary access token expires: ", as.POSIXct(token_exp)))
logger::log_debug(base::paste0("hawkinR/get_tags -> Temporary access token expires: ", base::as.POSIXct(token_exp)))
}

# 3. ----- Build URL Request -----
Expand Down Expand Up @@ -104,7 +97,8 @@ get_tags <- function() {
}

if (!base::is.null(error_message)) {
stop(logger::log_error(base::paste0("hawkinR/get_tags -> ", error_message)))
logger::log_error(base::paste0("hawkinR/get_tags -> ", error_message))
stop(error_message)
}

# Response Table
Expand Down
16 changes: 5 additions & 11 deletions R/get_teams.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,7 @@ get_teams <- function() {
# Log Trace
logger::log_trace(base::paste0("hawkinR -> Run: get_teams"))

# Save the current setting
old_show_error_messages <- base::getOption("show.error.messages")
base::on.exit(base::options(show.error.messages = old_show_error_messages),
add = TRUE)

# Disable error messages
base::options(show.error.messages = FALSE)

# 2. ----- Parameter Validation -----
# 2. ----- Parameter Validation -----

# Retrieve access token and expiration from environment variables
aToken <- base::Sys.getenv("accessToken")
Expand All @@ -60,10 +52,11 @@ get_teams <- function() {
# Check for Access Token and Expiration
if (base::is.null(aToken) ||
token_exp <= base::as.numeric(base::Sys.time())) {
logger::log_error("hawkinR/get_teams -> Access token not available or expired. Call get_access() to obtain it.")
stop("Access token not available or expired. Call get_access() to obtain it.")
} else {
# Log Debug
logger::log_debug(base::paste0("hawkinR/get_teams -> Temporary access token expires: ", as.POSIXct(token_exp)))
logger::log_debug(base::paste0("hawkinR/get_teams -> Temporary access token expires: ", base::as.POSIXct(token_exp)))
}

# 3. ----- Build URL Request -----
Expand Down Expand Up @@ -99,7 +92,8 @@ get_teams <- function() {
}

if (!base::is.null(error_message)) {
stop(logger::log_error(base::paste0("hawkinR/get_teams -> ",error_message)))
logger::log_error(base::paste0("hawkinR/get_teams -> ",error_message))
stop(error_message)
}

# Response Table
Expand Down
Loading

0 comments on commit d65adc1

Please sign in to comment.