ffverse / ffscrapr

R API Client for Fantasy Football League Platforms
https://ffscrapr.ffverse.com
Other
81 stars 22 forks source link

Error in ff_scoringhistory #365

Closed mcarman8 closed 2 years ago

mcarman8 commented 2 years ago

Describe the bug Yesterday everything was working fine, but today ff_scoringhistory throws one of two errors, screenshots attached. Maybe an api or weekly data update changed/failed? It fails with multiple leagues. It throws the "warning" error if the seasons parameter is not explicitly defined, and throws the "error" error when seasons is explicitly defined.

Reprex To get "warning" error:

library(ffsimulator)
library(ffscrapr)
season=2022 #NFL Season
league_id=793392140196614144 #Your sleeper league_id
conn <- sleeper_connect(season,league_id);

league_info <- ffscrapr::ff_league(conn)
print("madeit")
scoring_history <- ffscrapr::ff_scoringhistory(conn, 2012:(season-1))
print("didnt make it")

To get "error" error:

library(ffsimulator)
library(ffscrapr)
season=2022 #NFL Season
league_id=793392140196614144 #Your sleeper league_id
conn <- sleeper_connect(season,league_id);

league_info <- ffscrapr::ff_league(conn)
print("madeit")
scoring_history <- ffscrapr::ff_scoringhistory(conn, seasons=2012:(season-1))
print("didnt make it")

Expected behavior No errors and a scoring_history object is properly created

Session information

R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggridges_0.5.3    ggplot2_3.3.6     ffscrapr_1.4.7    ffsimulator_1.2.0

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.9          plyr_1.8.7          pillar_1.8.0        compiler_4.2.1     
 [5] qs_0.25.3           tools_4.2.1         jsonlite_1.8.0      memoise_2.0.1      
 [9] lifecycle_1.0.1     tibble_3.1.8        checkmate_2.1.0     gtable_0.3.0       
[13] pkgconfig_2.0.3     rlang_1.0.4         cli_3.3.0           curl_4.3.2         
[17] fastmap_1.1.0       withr_2.5.0         dplyr_1.0.9         httr_1.4.3         
[21] generics_0.1.3      vctrs_0.4.1         tictoc_1.0.1        grid_4.2.1         
[25] tidyselect_1.1.2    RApiSerialize_0.1.0 glue_1.6.2          data.table_1.14.2  
[29] R6_2.5.1            fansi_1.0.3         tidyr_1.2.0         ratelimitr_0.4.1   
[33] purrr_0.3.4         magrittr_2.0.3      nflreadr_1.2.0      backports_1.4.1    
[37] scales_1.2.0        ellipsis_0.3.2      assertthat_0.2.1    colorspace_2.0-3   
[41] stringfish_0.15.7   utf8_1.2.2          RcppParallel_5.1.5  munsell_0.5.0      
[45] cachem_1.0.6       

Screenshots "Warning" error: error1 "Error" error: error2

tanho63 commented 2 years ago

This is related/duplicate to ffverse/ffscrapr#364 and involves a recent nflreadr problem with rosters

tanho63 commented 2 years ago

Resolved in nflverse/nflfastR-roster#47

R> library(ffscrapr)
R> season=2022 #NFL Season
R> league_id=793392140196614144 #Your sleeper league_id
R> conn <- sleeper_connect(season,league_id);
R> league_info <- ffscrapr::ff_league(conn)
R> print("madeit")
[1] "madeit"

R> scoring_history <- ffscrapr::ff_scoringhistory(conn, seasons=2012:(season-1))

R> print("didnt make it")
[1] "didnt make it"

R> scoring_history
# A tibble: 115,540 × 38
   season  week gsis_id    sportradar_id sleeper_id player_name   pos   team  points
    <int> <int> <chr>      <chr>         <chr>      <chr>         <chr> <chr>  <dbl>
 1   1999    11 00-0016479 NA            NA         Pat Tillman   DB    ARI     0   
 2   1999     4 00-0001907 NA            NA         Dave Brown    QB    ARI     1.2 
 3   1999     5 00-0001907 NA            NA         Dave Brown    QB    ARI     1.64
 4   1999     6 00-0001907 NA            NA         Dave Brown    QB    ARI     7.28
 5   1999     8 00-0001907 NA            NA         Dave Brown    QB    ARI     0.28
 6   1999     9 00-0001907 NA            NA         Dave Brown    QB    ARI     8.26
 7   1999    10 00-0001907 NA            NA         Dave Brown    QB    ARI    10.3 
 8   1999    11 00-0001907 NA            NA         Dave Brown    QB    ARI     6.3 
 9   1999    12 00-0001907 NA            NA         Dave Brown    QB    ARI     4.44
10   1999     8 00-0006410 NA            NA         Chris Greisen QB    ARI     0.16
# … with 115,530 more rows, and 29 more variables: receiving_fumbles_lost <dbl>,
#   rushing_fumbles_lost <dbl>, sack_fumbles_lost <dbl>, interceptions <dbl>,
#   passing_2pt_conversions <dbl>, passing_tds <dbl>, passing_yards <dbl>,
#   receiving_2pt_conversions <dbl>, receiving_tds <dbl>, receiving_yards <dbl>,
#   receptions <dbl>, rushing_2pt_conversions <dbl>, rushing_tds <dbl>,
#   rushing_yards <dbl>, fg_made_0_19 <dbl>, fg_made_20_29 <dbl>, fg_made_30_39 <dbl>,
#   fg_made_40_49 <dbl>, fg_made_50_59 <dbl>, fg_made_60_ <dbl>, fg_missed <dbl>, …