-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* v0.2.0: add player id * redoc * add envvars to gha script * use bearer auth function --------- Co-authored-by: Sebastian Carl <[email protected]>
- Loading branch information
Showing
12 changed files
with
146 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
on: | ||
schedule: | ||
# runs every day at 7:00 AM UTC = 3AM ET | ||
- cron: '0 7 * * *' | ||
workflow_dispatch: | ||
|
||
name: update_otc | ||
|
||
jobs: | ||
update: | ||
name: update data | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 40 | ||
env: | ||
GITHUB_PAT: ${{ secrets.NFLVERSE_GH_TOKEN }} | ||
OTC_PLAYERID_ENDPOINT: ${{ secrets.OTC_PLAYERID_ENDPOINT }} | ||
OTC_API_KEY: ${{ secrets.OTC_API_KEY }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: r-lib/actions/setup-r@v2 | ||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
cache-version: 1 | ||
extra-packages: | | ||
nflverse/nflverse-data | ||
nflverse/nflreadr | ||
ropensci/piggyback | ||
local::. | ||
any::arrow | ||
any::qs | ||
- name: Run otc update script | ||
run: Rscript data-raw/release_otc_player_ids.R |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
.Rdata | ||
.httr-oauth | ||
.DS_Store | ||
.Renviron |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: rotc | ||
Title: Functions to Access OTC Data | ||
Version: 0.0.0.9004 | ||
Version: 0.2.0 | ||
Authors@R: | ||
person("Carl", "Sebastian", , "[email protected]", role = c("aut", "cre")) | ||
Description: A set of functions to access over the cap data. | ||
|
@@ -14,14 +14,16 @@ Imports: | |
dplyr (>= 1.0.8), | ||
httr2 (>= 0.1.1), | ||
janitor (>= 2.1.0), | ||
jsonlite (>= 1.8.0), | ||
magrittr, | ||
purrr (>= 0.3.4), | ||
readr (>= 2.1.2), | ||
rlang (>= 1.0.2), | ||
rvest (>= 1.0.2), | ||
stringi (>= 1.7.6), | ||
stringi (>= 1.7.6), | ||
stringr (>= 1.4.0), | ||
tidyr (>= 1.2.0), | ||
xml2 (>= 1.3.3) | ||
Encoding: UTF-8 | ||
Roxygen: list(markdown = TRUE) | ||
RoxygenNote: 7.2.0 | ||
RoxygenNote: 7.2.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export("%>%") | ||
export(otc_historical_contracts) | ||
export(otc_historical_contracts_all) | ||
export(otc_player_details) | ||
import(dplyr) | ||
export(otc_player_ids) | ||
importFrom(magrittr,"%>%") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#' Retrieve player ID mappings | ||
#' | ||
#' @param endpoint endpoint (defaults to environment variable OTC_PLAYERID_ENDPOINT) | ||
#' @param api_key api key (defaults to environment variable OTC_API_KEY) | ||
#' | ||
#' @export | ||
otc_player_ids <- function(endpoint = Sys.getenv("OTC_PLAYERID_ENDPOINT"), | ||
api_key = Sys.getenv("OTC_API_KEY")){ | ||
stopifnot( | ||
length(endpoint) == 1 && nchar(endpoint) > 0, | ||
length(api_key) == 1 && nchar(api_key) > 0 | ||
) | ||
|
||
resp <- httr2::request(endpoint) %>% | ||
httr2::req_auth_bearer_token(api_key) %>% | ||
httr2::req_retry(max_tries = 3) %>% | ||
httr2::req_perform() | ||
|
||
player_ids <- resp %>% | ||
httr2::resp_body_string() %>% | ||
jsonlite::fromJSON() %>% | ||
dplyr::mutate_all( ~replace(.x, .x %in% c("", 0), NA)) %>% | ||
dplyr::rename( | ||
gsis_it_id = gsis_id, | ||
gsis_id = gsis_player_id | ||
) | ||
|
||
return(player_ids) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,5 @@ | |
"_PACKAGE" | ||
|
||
## usethis namespace: start | ||
#' @import dplyr | ||
## usethis namespace: end | ||
NULL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#' Pipe operator | ||
#' | ||
#' See \code{magrittr::\link[magrittr:pipe]{\%>\%}} for details. | ||
#' | ||
#' @name %>% | ||
#' @rdname pipe | ||
#' @keywords internal | ||
#' @export | ||
#' @importFrom magrittr %>% | ||
#' @usage lhs \%>\% rhs | ||
#' @param lhs A value or the magrittr placeholder. | ||
#' @param rhs A function call using the magrittr semantics. | ||
#' @return The result of calling `rhs(lhs)`. | ||
NULL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
player_ids <- rotc::otc_player_ids() | ||
|
||
nflversedata::nflverse_save( | ||
data_frame = player_ids, | ||
file_name = "otc_players", | ||
nflverse_type = "OverTheCap Player IDs", | ||
release_tag = "players_components" | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters