Skip to content

Commit

Permalink
pass checks and add extended timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
pbulsink committed Sep 5, 2023
1 parent 62bf369 commit 8bfb11e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: naturalstattrick
Type: Package
Title: Natural Stat Trick Data in R
Version: 0.1.0
Description: This package allows for accessing of Natural Stat Trick (https://naturalstattrick.com) data in R. This package currently accesses just game report data. It has built-in caching, rate-limiting, and auto-retry on connection failures. See more information at https://naturalstattrick.com/glossary
Description: This package allows for accessing of Natural Stat Trick (https://naturalstattrick.com) data in R. This package currently accesses just game report data. It has built-in caching, rate-limiting, and auto-retry on connection failures. See more information at https://naturalstattrick.com/glossary.
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Expand Down
1 change: 1 addition & 0 deletions R/game.R
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ nst_game_call <- function(season, game_id) {
)) %>%
httr2::req_throttle(180 / 3600) %>% # 180 calls per h
httr2::req_retry(5) %>%
httr2::req_timeout(30) %>%
httr2::req_user_agent("naturalstattrick r package - github.com/pbulsink/naturalstattrick") %>%
httr2::req_perform() %>%
httr2::resp_body_html()
Expand Down
4 changes: 2 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ clear_cache <- function() {
#' @param gid gameID in YYYY0#GGGG format, or NULL to use season and game_id directly
#' @param season season in YYYYYYYY format (i.e. 20072008). Overwritten by calculated season if gid is provided
#' @param game_id game_id in ##### format (i.e. 21200). Overwritten by calculated game_id if gid is provided
#' @param file csv file to add the selected game to
#' @param filename csv file to add the selected game to
#'
#' @return None, called for side-effects
#' @export
Expand All @@ -45,7 +45,7 @@ write_game_df_to_file <- function(gid, season = NULL, game_id = NULL, filename =
if (system2("grep", paste0('-l "', gid, '" ', filename), stdout = FALSE) != 0) {
nstdf <- nst_report_df(season, game_id)
nstdf$game_id <- gid
write.table(nstdf, file = filename, append = TRUE, row.names = FALSE, col.names = FALSE, sep = ",", )
utils::write.table(nstdf, file = filename, append = TRUE, row.names = FALSE, col.names = FALSE, sep = ",", )
closeAllConnections()
}
}
2 changes: 1 addition & 1 deletion man/write_game_df_to_file.Rd

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

0 comments on commit 8bfb11e

Please sign in to comment.