stattleship / stattleship-r

Stattleship R Wrapper
https://api.stattleship.com/
MIT License
48 stars 14 forks source link

quick fix for 0 results returned #23

Closed tcash21 closed 8 years ago

tcash21 commented 8 years ago

Need to better handle this but hotfixes for now so it's usable when looping through players that have no game_logs returned.

Btibert3 commented 8 years ago

I got a fail on the original code.

options(stringsAsFactors = F)

## remove and re-install
remove.packages("stattleshipR")

## install
devtools::install_github("stattleship/stattleship-r", ref="tanya-pages")
library(stattleshipR)
library(dplyr)

## this fails
set_token("token_here")
sport <- "HOCKEY"
ss_get_result(sport=sport)

## reset
remove.packages("stattleshipR")
devtools::install_github("stattleship/stattleship-r")
library(stattleshipR)
library(dplyr)

## but this does
set_token("token_here")
ss_get_result(sport=sport)

The error is Error in ss_get_result(sport = sport) : object 'total_results' not found so it looks like it's failing on the results from the request, as total_results doesn't exist.

Pushed a change to the branch, the original issue and the issue above both seemed to have pass.

tcash21 commented 8 years ago

Fix for single results where pagination isn't used and total does not exist in the header. When this is the case, total_results and pages are both set to 1.