ffverse / ffscrapr

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

Fix `ff_starters()` for multi-week playoff ESPN leagues #422

Closed tonyelhabr closed 7 months ago

tonyelhabr commented 7 months ago

Fixes #421.

packageVersion("ffscrapr")
#> [1] '1.4.8.15'
conn22 <- ffscrapr::espn_connect(
  season = 2022,
  league_id = 899513
)

## previously, this would error at index 16 (NFL week 16, second week of 1st round of playoffs)
starters22 <- ffscrapr::ff_starters(conn22, weeks = 1:18)
str(starters22, max.level = 1)
#> tibble [3,495 × 12] (S3: tbl_df/tbl/data.frame)

conn23 <- ffscrapr::espn_connect(
  season = 2023,
  league_id = 899513
)

## nothing broken for this year (no playoffs started)
starters23 <- ffscrapr::ff_starters(conn23, weeks = 1:18)
str(starters23, max.level = 1)
#> tibble [1,999 × 12] (S3: tbl_df/tbl/data.frame)
tonyelhabr commented 7 months ago

Looks good, thanks for the comment details! Can you add a test case that covers this, and ensure it runs if you have the MOCK_BYPASS envvar set?

Just pushed a change! Let me know if I've done it correctly. I think I may need to add data to the cache ZIP in the tests-devel release, although I'm not totally sure. (I haven't used httptest before 🤷 .)

tanho63 commented 7 months ago

I think I may need to add data to the cache ZIP in the tests-devel release, although I'm not totally sure. (I haven't used httptest before 🤷 .)

Unsure if you've permissions to, I was trying to figure out the best way to do that

tonyelhabr commented 7 months ago

LGTM, I think I did the thing backend that should make tests-devel.zip work again...

🥳