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

hawkinR v1.0.4 - Updated to match new Hawkin Beta API Doc 1.10 #19

Merged
merged 1 commit into from
Feb 15, 2024
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
8 changes: 8 additions & 0 deletions .Rhistory
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,11 @@ base::paste0("?syncFrom=",from)
base::paste0("?from=",from)
}
devtools::load_all(".")
pkgdown::build_site()
library(usethis)
edit_r_environ()
install.packages("remotes")
library(remotes)
library(remotes)
install_github("laureng_hd/hawkinR")
install_github("HawkinDynamics/hawkinR")
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.0.3.2
Version: 1.0.4
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
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## hawkinR v1.0.4

# changes to API endpoint (inclusion of test tag details). All `get_tests_...` function outputs now
include tag Ids, names, and description columns with the prefix 'test_type_tag_'. These can be
found after 'test_type_cacnnonicalId' column.

## hawkinR v1.0.3.2

# bug fixes to all `get_tests_...` functions to handle NULL externalIds
Expand Down
40 changes: 37 additions & 3 deletions R/get_tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,17 @@
#'
#' **segment** *chr* Description of the test type and trial number of the session (testType:trialNo)
#'
#' **testType_id** *chr* Id of the test type of the trial
#' **test_type_id** *chr* Id of the test type of the trial
#'
#' **testType_name** *chr* Name of the test type of the trial
#' **test_type_name** *chr* Name of the test type of the trial
#'
#' **testType_canonicalId** *chr* Canonical Id of the test type of the trial
#' **test_type_canonicalId** *chr* Canonical Id of the test type of the trial
#'
#' **test_type_tag_ids** *chr* String of Ids associated with tags used during the test trial
#'
#' **test_type_tag_names** *chr* String of names of tags used during the test trial
#'
#' **test_type_tag_desc** *chr* String of descriptions of tags used during the test trial
#'
#' **athlete_id** *chr* Unique Id of the athlete
#'
Expand Down Expand Up @@ -245,6 +251,34 @@ get_tests <- function(from = NULL, to = NULL, sync = FALSE, active = TRUE) {
# Create testType df
t <- x$testType

# extract tags array from data frame
tagList <- t$tags

# Define a function to pad empty data frames with NA values
# and condense multiple rows into one with values separated by '|'
pad_and_condense <- function(df) {
if (base::is.null(df) || base::nrow(df) == 0) {
return(base::data.frame(tagIds = NA, tagNames = NA, tagDesc = NA))
} else {
condensed_row <- base::data.frame(
tagIds = base::paste(df$id, collapse = ','),
tagNames = base::paste(df$name, collapse = ','),
tagDesc = base::ifelse(all(df$description == ""), NA, base::paste(df$description, collapse = '|'))
)
return(condensed_row)
}
}

# Apply the padding function to all data frames in the list
paddedTagList <- base::lapply(tagList, pad_and_condense)

# Combine all data frames into one
tagsDF <- base::do.call(rbind, paddedTagList)

# Replace new tags columns to testType df
t <- dplyr::select(t, -'tags')
t <- base::cbind(t,tagsDF)

# append testType prefix
base::names(t) <- base::paste0('testType_', base::names(t))

Expand Down
34 changes: 34 additions & 0 deletions R/get_tests_ath.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
#'
#' **testType.canonicalId** *chr* Canonical Id of the test type of the trial
#'
#' **test_type_tag_ids** *chr* String of Ids associated with tags used during the test trial
#'
#' **test_type_tag_names** *chr* String of names of tags used during the test trial
#'
#' **test_type_tag_desc** *chr* String of descriptions of tags used during the test trial
#'
#' **athlete.id** *chr* Unique Id of the athlete
#'
#' **athlete.name** *chr* Athlete given name
Expand Down Expand Up @@ -245,6 +251,34 @@ get_tests_ath <- function(athleteId, from = NULL, to = NULL, sync = FALSE, activ
# Create testType df
t <- x$testType

# extract tags array from data frame
tagList <- t$tags

# Define a function to pad empty data frames with NA values
# and condense multiple rows into one with values separated by '|'
pad_and_condense <- function(df) {
if (base::is.null(df) || base::nrow(df) == 0) {
return(base::data.frame(tagIds = NA, tagNames = NA, tagDesc = NA))
} else {
condensed_row <- base::data.frame(
tagIds = base::paste(df$id, collapse = ','),
tagNames = base::paste(df$name, collapse = ','),
tagDesc = base::ifelse(all(df$description == ""), NA, base::paste(df$description, collapse = '|'))
)
return(condensed_row)
}
}

# Apply the padding function to all data frames in the list
paddedTagList <- base::lapply(tagList, pad_and_condense)

# Combine all data frames into one
tagsDF <- base::do.call(rbind, paddedTagList)

# Replace new tags columns to testType df
t <- dplyr::select(t, -'tags')
t <- base::cbind(t,tagsDF)

# append testType prefix
base::names(t) <- base::paste0('testType_', base::names(t))

Expand Down
34 changes: 34 additions & 0 deletions R/get_tests_group.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
#'
#' **testType.canonicalId** *chr* Canonical Id of the test type of the trial
#'
#' **test_type_tag_ids** *chr* String of Ids associated with tags used during the test trial
#'
#' **test_type_tag_names** *chr* String of names of tags used during the test trial
#'
#' **test_type_tag_desc** *chr* String of descriptions of tags used during the test trial
#'
#' **athlete.id** *chr* Unique Id of the athlete
#'
#' **athlete.name** *chr* Athlete given name
Expand Down Expand Up @@ -274,6 +280,34 @@ get_tests_group <- function(groupId, from = NULL, to = NULL, sync = FALSE, activ
# Create testType df
t <- x$testType

# extract tags array from data frame
tagList <- t$tags

# Define a function to pad empty data frames with NA values
# and condense multiple rows into one with values separated by '|'
pad_and_condense <- function(df) {
if (base::is.null(df) || base::nrow(df) == 0) {
return(base::data.frame(tagIds = NA, tagNames = NA, tagDesc = NA))
} else {
condensed_row <- base::data.frame(
tagIds = base::paste(df$id, collapse = ','),
tagNames = base::paste(df$name, collapse = ','),
tagDesc = base::ifelse(all(df$description == ""), NA, base::paste(df$description, collapse = '|'))
)
return(condensed_row)
}
}

# Apply the padding function to all data frames in the list
paddedTagList <- base::lapply(tagList, pad_and_condense)

# Combine all data frames into one
tagsDF <- base::do.call(rbind, paddedTagList)

# Replace new tags columns to testType df
t <- dplyr::select(t, -'tags')
t <- base::cbind(t,tagsDF)

# append testType prefix
base::names(t) <- base::paste0('testType_', base::names(t))

Expand Down
34 changes: 34 additions & 0 deletions R/get_tests_team.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
#'
#' **testType.canonicalId** *chr* Canonical Id of the test type of the trial
#'
#' **test_type_tag_ids** *chr* String of Ids associated with tags used during the test trial
#'
#' **test_type_tag_names** *chr* String of names of tags used during the test trial
#'
#' **test_type_tag_desc** *chr* String of descriptions of tags used during the test trial
#'
#' **athlete.id** *chr* Unique Id of the athlete
#'
#' **athlete.name** *chr* Athlete given name
Expand Down Expand Up @@ -274,6 +280,34 @@ get_tests_team <- function(teamId, from = NULL, to = NULL, sync = FALSE, active
# Create testType df
t <- x$testType

# extract tags array from data frame
tagList <- t$tags

# Define a function to pad empty data frames with NA values
# and condense multiple rows into one with values separated by '|'
pad_and_condense <- function(df) {
if (base::is.null(df) || base::nrow(df) == 0) {
return(base::data.frame(tagIds = NA, tagNames = NA, tagDesc = NA))
} else {
condensed_row <- base::data.frame(
tagIds = base::paste(df$id, collapse = ','),
tagNames = base::paste(df$name, collapse = ','),
tagDesc = base::ifelse(all(df$description == ""), NA, base::paste(df$description, collapse = '|'))
)
return(condensed_row)
}
}

# Apply the padding function to all data frames in the list
paddedTagList <- base::lapply(tagList, pad_and_condense)

# Combine all data frames into one
tagsDF <- base::do.call(rbind, paddedTagList)

# Replace new tags columns to testType df
t <- dplyr::select(t, -'tags')
t <- base::cbind(t,tagsDF)

# append testType prefix
base::names(t) <- base::paste0('testType_', base::names(t))

Expand Down
34 changes: 34 additions & 0 deletions R/get_tests_type.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
#'
#' **testType.canonicalId** *chr* Canonical Id of the test type of the trial
#'
#' **test_type_tag_ids** *chr* String of Ids associated with tags used during the test trial
#'
#' **test_type_tag_names** *chr* String of names of tags used during the test trial
#'
#' **test_type_tag_desc** *chr* String of descriptions of tags used during the test trial
#'
#' **athlete.id** *chr* Unique Id of the athlete
#'
#' **athlete.name** *chr* Athlete given name
Expand Down Expand Up @@ -264,6 +270,34 @@ get_tests_type <- function(typeId, from = NULL, to = NULL, sync = FALSE, active=
# Create testType df
t <- x$testType

# extract tags array from data frame
tagList <- t$tags

# Define a function to pad empty data frames with NA values
# and condense multiple rows into one with values separated by '|'
pad_and_condense <- function(df) {
if (base::is.null(df) || base::nrow(df) == 0) {
return(base::data.frame(tagIds = NA, tagNames = NA, tagDesc = NA))
} else {
condensed_row <- base::data.frame(
tagIds = base::paste(df$id, collapse = ','),
tagNames = base::paste(df$name, collapse = ','),
tagDesc = base::ifelse(all(df$description == ""), NA, base::paste(df$description, collapse = '|'))
)
return(condensed_row)
}
}

# Apply the padding function to all data frames in the list
paddedTagList <- base::lapply(tagList, pad_and_condense)

# Combine all data frames into one
tagsDF <- base::do.call(rbind, paddedTagList)

# Replace new tags columns to testType df
t <- dplyr::select(t, -'tags')
t <- base::cbind(t,tagsDF)

# append testType prefix
base::names(t) <- base::paste0('testType_', base::names(t))

Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ knitr::opts_chunk$set(
[![R-CMD-check](https://github.com/HawkinDynamics/hawkinR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/HawkinDynamics/hawkinR/actions/workflows/R-CMD-check.yaml) [![Last-changedate](https://img.shields.io/badge/last%20change-`r gsub('-', '--', Sys.Date())`-yellowgreen.svg)](/commits/master) [![license](https://img.shields.io/badge/license-MIT%20+%20file%20LICENSE-lightgrey.svg)](https://choosealicense.com/)
[![minimal R version](https://img.shields.io/badge/R%3E%3D-`r "3.5.0"`-6666ff.svg)](https://cran.r-project.org/)
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) [![lifecycle](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://www.tidyverse.org/lifecycle/#stable)
[![packageversion](https://img.shields.io/badge/Package%20version-`r "1.0.3.2"`-orange.svg?style=flat-square)](commits/master)
[![packageversion](https://img.shields.io/badge/Package%20version-`r "1.0.4"`-orange.svg?style=flat-square)](commits/master)
[![thanks-md](https://img.shields.io/badge/THANKS-md-ff69b4.svg)](THANKS.md)

<!-- badges: end -->
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
<!-- badges: start -->

[![R-CMD-check](https://github.com/HawkinDynamics/hawkinR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/HawkinDynamics/hawkinR/actions/workflows/R-CMD-check.yaml)
[![Last-changedate](https://img.shields.io/badge/last%20change-2024--02--01-yellowgreen.svg)](/commits/master)
[![Last-changedate](https://img.shields.io/badge/last%20change-2024--02--15-yellowgreen.svg)](/commits/master)
[![license](https://img.shields.io/badge/license-MIT%20+%20file%20LICENSE-lightgrey.svg)](https://choosealicense.com/)
[![minimal R
version](https://img.shields.io/badge/R%3E%3D-3.5.0-6666ff.svg)](https://cran.r-project.org/)
[![Project Status: Active – The project has reached a stable, usable
state and is being actively
developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![lifecycle](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://www.tidyverse.org/lifecycle/#stable)
[![packageversion](https://img.shields.io/badge/Package%20version-1.0.3.2-orange.svg?style=flat-square)](commits/master)
[![packageversion](https://img.shields.io/badge/Package%20version-1.0.4-orange.svg?style=flat-square)](commits/master)
[![thanks-md](https://img.shields.io/badge/THANKS-md-ff69b4.svg)](THANKS.md)

<!-- badges: end -->
Expand Down
12 changes: 9 additions & 3 deletions man/get_tests.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions man/get_tests_ath.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions man/get_tests_group.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions man/get_tests_team.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions man/get_tests_type.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading