Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always return schedule data, even if gamecenter json is unavailable #68

Open
derek-adair opened this issue Aug 9, 2019 · 8 comments
Open
Assignees

Comments

@derek-adair
Copy link
Owner

derek-adair commented Aug 9, 2019

I have strict requirements regarding the timing of games, namely, I want to execute code when a game is exactly 10 minutes out. Over the last two years this has been inconsistent; I suspect it is this line, and that the game-center json is unavailable.

As I do not want to re-impliment nflgame.live in my project that uses nflgame; My inclination is to have nflgame.game.Game return game meta data even when there is no game-center json. I am trying to implement this with as little side effects as I can, but this likely has a LOT of implications throughout the code.

@derek-adair derek-adair self-assigned this Aug 9, 2019
@derek-adair derek-adair changed the title Active game list is inconsistent Always return schedule data, even if gamecenter json is unavailable Aug 23, 2019
@derek-adair derek-adair pinned this issue Aug 23, 2019
@derek-adair
Copy link
Owner Author

derek-adair commented Aug 23, 2019

Ok! took a crack at this. I think i did this in a way that will be unobtrusive. PLEASE take a look at my commit, and give me any feedback that you can provide.

Key points:

  1. Methods that return stats should return empty lists (e.g. max_player_stats)
  2. new game attribute: gcJsonAvailable for an easy flag (probably only useful for debugging)
  3. passing kwargs (games_gen, nflgame.one) into game instead of just eid or fpath
  4. if _get_json_data returns None; stub out an empty object
  5. limiting the attributes constructed if there is no game center data

@derek-adair
Copy link
Owner Author

derek-adair commented Aug 23, 2019

This is made available under the 2.0.1a3 release in pypi.

OR you can check out dev and build locally

make dev-install

@derek-adair
Copy link
Owner Author

This... doesn't work. It breaks when you pass nflgame.game.Game(<eid_string>) and the game is in the future. My thoughts were to always pass the entire schedule object for the game as kwargs.

Unsure the best way to do this anymore. Maybe if the extra schedule data isn't included, fetch it?

This would require modifying _search_schedule_by_eid, or something along those lines.

derek-adair added a commit that referenced this issue Aug 23, 2019
- _search_schedule by eid
- _search_schedule doesn't require year param now
- IF the gamecenter data isn't available...
   * Check to see if the schedule data was in the kwargs
   * If not > search for the data by EID.
@derek-adair
Copy link
Owner Author

derek-adair commented Aug 23, 2019

  • _seach_schedule() takes eid now
  • nflgame.game.Game(<eid>) works if the game is in the future

derek-adair added a commit that referenced this issue Aug 23, 2019
- _search_schedule returns a single game if eid is matched
- live.py now has a method for returning _cur_season_phase
@derek-adair
Copy link
Owner Author

Fixed _search_schedule() by eid: It was failing b/c we are in pre-season and the default is REG.

I decided to just return a flat dict of the schedule data when an eid matches to simplify this.

@derek-adair
Copy link
Owner Author

Ruminating on if these changes are worth it.... I may just implement a live-esque script that just searches the schedule by week.

derek-adair added a commit that referenced this issue Sep 26, 2019
- _search_schedule by eid
- _search_schedule doesn't require year param now
- IF the gamecenter data isn't available...
   * Check to see if the schedule data was in the kwargs
   * If not > search for the data by EID.
derek-adair added a commit that referenced this issue Sep 26, 2019
- _search_schedule returns a single game if eid is matched
- live.py now has a method for returning _cur_season_phase
@nczeak
Copy link

nczeak commented Feb 11, 2020

I'm still having issues with this. It seems as though there are two try/except blocks to handle an HTTPError, and the nested block isn't allowing the outer block to properly handle the exception. Everything works perfectly for me when I delete the except urllib.error.HTTPError segment within _get_json_data(). Otherwise, instead of halting and returning None, __new__() will set rawData = None and cause an error when trying to decode.

@derek-adair derek-adair unpinned this issue Mar 27, 2020
@derek-adair
Copy link
Owner Author

derek-adair commented Apr 24, 2020

@nczeak - Can you submit a PR or give some line numbers? I'd love to have more confidence in pushing this code beyond a "beta release"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants