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

Implement NFL Play-By-Play #6

Open
RLovelett opened this issue Apr 8, 2013 · 5 comments
Open

Implement NFL Play-By-Play #6

RLovelett opened this issue Apr 8, 2013 · 5 comments

Comments

@RLovelett
Copy link
Owner

Play-By-Play

Schema

Syntax: http://api.sportsdatallc.org/nfl-[access_level][version]/schema/pbp-v1.0.xsd?api_key=[your_api_key]

Schema Example

Feed

Syntax: http://api.sportsdatallc.org/nfl-[access_level][version]/[year]/[nfl_season]/[nfl_season_week]/[away_team]/[home_team]/pbp.[format]?api_key=[your_api_key]

Parameter Format Notes

[access_level] = Real-Time (rt), Premium (p), Standard (s), Basic (b), Trial (t)

[version] = whole number (sequential, starting with the number 1)

[year] = yyyy

[nfl_season] = Preseason (PRE), Regular Season (REG), Postseason (PST)

[nfl_season_week] = 1 - 17 (Week 0 of Preseason is Hall of Fame game)

[format] = xml

[home_team], [away_team] = <see schedule feed>

Feed Example

@janjiss
Copy link
Contributor

janjiss commented Jun 2, 2015

@RLovelett Hey, I am working on NFL Play by Play endpoint and wanted to get your opinion before I proceed. The problem with Play by Play is that it's collections are not homogenous, it means that there are "drive" type elements and "event" elements in the "pbp" array. They differ in their structure. I have three approaches in my mind that might work out, but they are all less than ideal.

  1. To create a "generic" event class that might or might not contain certain values from play by play event. I can see this going all sorts of wrong since constant nil checks suck.
  2. To map event by type to a certain class. This leaves us with the problem of type checking.
  3. To have methods for quarter like - quarter.drive_events and collect them all that way. This would make the structure of the quarter class not map directly to API.

I am curious, maybe you had other ideas in mind?

@TheKidCoder
Copy link

+1 For mapping events to types. I think it's the best choice. We'll need to come up with a solid interface to extend from but I think duck typing from there would work well enough.

@RLovelett
Copy link
Owner Author

I'll be honest this is one that I didn't really look at in any detail. @JanjiS it's easier for me to speak in code regarding proposals. Can you show a snippet for any of the ones you like the most?

@janjiss
Copy link
Contributor

janjiss commented Jun 3, 2015

@RLovelett Sure, here is the code that I am working one, please note that it is a "Work in progress": https://github.com/DiatomEnterprises/sports_data_api/blob/master/lib/sports_data_api/nfl/play_by_play.rb

@RLovelett
Copy link
Owner Author

Ok now that I've looked at some of the code. I think I'm starting to agree with @TheKidCoder. Making the events into types feels the cleanest to me. In my mind, the code I imagine writing with the type checking becomes the most readable.

Example

events = game.pbp # events/php is an Enumerable?
case events.first.class
when EventA
  # stuff
when EventB
  # stuff
...

or even

events = game.pbp # events/php is an Enumerable?
if events.first.is_a?(EventA)
  # do something great
end

@janjiss I tried looking over the specs to get a feel for how you expect the interface to be used but I'm not sure I can see it. Can you provide just some notional examples here in the discussion? Maybe that would help me make up my mind. @TheKidCoder could I impose on you to do the same.

I would like the implementation to support the usage and since I am not actually going to use it. I'm not sure I have a clear picture in my mind.

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

3 participants