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

Los Angles Charger Issues #252

Closed
mesee298 opened this issue Aug 14, 2017 · 11 comments
Closed

Los Angles Charger Issues #252

mesee298 opened this issue Aug 14, 2017 · 11 comments

Comments

@mesee298
Copy link

mesee298 commented Aug 14, 2017

So, after reading about LA Rams changes last year, I was able to add the Chargers for the schedule and it works great. Now the player table still shows on 'SD' instead of 'LAC'. I ran update-players.py, and players.json still shows as 'SD'. I assume this is an issue with nfl.com, but you know what happens when you assume. :)

If it is an nfl.com issue, when have you seen it rectified in the past?

If it isn't an nfl.com issue, what can I do to make the players show up on 'LAC'?

@javaschmava
Copy link

I think

insert into team values('LAC','Los Angeles', 'Chargers');

should fix it.

@ochawkeye
Copy link
Contributor

Just to confirm, what @javaschmava says is true.

D:\Python27\Scripts>python nfldb-update
-------------------------------------------------------------------------------
STARTING NFLDB UPDATE AT 2017-08-18 09:07:59.269000
Connecting to nfldb... done.
Setting timezone to UTC... done.
Locking write access to tables... done.
Updating season phase, year and week... done.
Bulk inserting data for 20 games...
        Sending batch of data to database.
        Sending batch of data to database.
        Sending batch of data to database.
        Sending batch of data to database.
Traceback (most recent call last):
  File "nfldb-update", line 39, in <module>
    nfldb.update.run(**vars(args))
  File "D:\Python27\lib\site-packages\nfldb\update.py", line 535, in run
    doit()
  File "D:\Python27\lib\site-packages\nfldb\update.py", line 525, in doit
    update_games(db, batch_size=batch_size)
  File "D:\Python27\lib\site-packages\nfldb\update.py", line 397, in update_games
    bulk_insert_game_data(cursor, scheduled, batch_size=batch_size)
  File "D:\Python27\lib\site-packages\nfldb\update.py", line 221, in bulk_insert_game_data
    do()
  File "D:\Python27\lib\site-packages\nfldb\update.py", line 188, in do
    nfldb.db._big_insert(cursor, table, bulk[table])
  File "D:\Python27\lib\site-packages\nfldb\db.py", line 356, in _big_insert
    % (table, insert_fields, values))
  File "D:\Python27\lib\site-packages\psycopg2\extras.py", line 223, in execute
    return super(RealDictCursor, self).execute(query, vars)
psycopg2.IntegrityError: insert or update on table "play" violates foreign key constraint "play_pos_team_fkey"
DETAIL:  Key (pos_team)=(LAC) is not present in table "team".

Performed this:

D:\Program Files (x86)\PostgreSQL\9.3\bin>psql.exe -U nfldb nfldb
Password for user nfldb:
psql (9.3.0)
WARNING: Console code page (437) differs from Windows code page (1252)
         8-bit characters might not work correctly. See psql reference
         page "Notes for Windows users" for details.
Type "help" for help.

nfldb=> insert into team values('LAC', 'Los Angeles', 'Chargers');
INSERT 0 1
nfldb=> \q

And re-ran nfldb-update


D:\Python27\Scripts>python nfldb-update
-------------------------------------------------------------------------------
STARTING NFLDB UPDATE AT 2017-08-18 09:13:17.904000
Connecting to nfldb... done.
Setting timezone to UTC... done.
Locking write access to tables... done.
Updating season phase, year and week... done.
Bulk inserting data for 20 games...
        Sending batch of data to database.
        Sending batch of data to database.
        Sending batch of data to database.
        Sending batch of data to database.
done.
Updating schedule JSON database...
Last updated: 2017-08-18 13:00:17.330000
done.
Updating schedule for (Preseason, 2017, 2)
done.
Closing database connection... done.
FINISHED NFLDB UPDATE AT 2017-08-18 09:14:39.922000
-------------------------------------------------------------------------------

@mesee298
Copy link
Author

This is fine for scoring, but I couldn't get it to update rosters. I had to remove SD from init.py to get the rosters to update correct.

@ochawkeye
Copy link
Contributor

That's interesting. I still have

    ['SD', 'San Diego', 'Chargers', 'San Diego Chargers', 'S.D.', 'SDG'],

in my ..\nflgame\__init__.py (I'm assuming that's the file you're talking about) and nothing about the LA Chargers in there and nflgame-update-players runs without error. I know for a long time last year the OAK roster URL redirected to the LA roster and would have guessed that was the case with this but I guess not if it isn't working for you.

@ochawkeye
Copy link
Contributor

As mentioned in nflgame #311, roster updates occur in the order that the teams appear in nflgame.teams. If "SD" record appeared in the list after the "LAC" record, the "SD" roster update would be overwriting the updated performed for "LAC". Re-ordering the nflgame.teams list allows to work around this while still allowing 2016 and before games to be queried.

@kennysushi
Copy link

Hrm arranging the 'SD' into an earlier position in the list seems not to work for me.

After completing:

insert into team values('LAC','Los Angeles', 'Chargers');
INSERT 0 1

nfldb-update worked just fine. I also see in the database both records of 'SD' and 'LAC'

nfldb=> SELECT COUNT() from play where pos_team = 'SD';
count
13441
nfldb=> SELECT COUNT(
) from play where pos_team = 'LAC';
count
72

but when I go to connect & pull data from nfldb the team is still showing up as 'UNK':

q = nfldb.Query(db)
q.game(season_year = 2017, week = 1 season_type='Regular')
for p in q.as_games():
print p

Regular 2017 week 1 on 09/11 at 10:20PM, UNK (21) at DEN (24)

That being said I do see 'SD' showing up correctly if I query for 2016.

Is there something I am missing here?

@ochawkeye
Copy link
Contributor

That game representation comes from here: https://github.com/BurntSushi/nfldb/blob/master/nfldb/types.py#L2458-L2464

The away team in this case comes from here:
https://github.com/BurntSushi/nfldb/blob/master/nfldb/types.py#L2114

So it looks like there's one more list the LA Chargers team needs to get added:
https://github.com/BurntSushi/nfldb/blob/master/nfldb/team.py

Since nflgame is a dependency of nfldb this list is probably a bit redundant between the two packages.

@kennysushi
Copy link

In team.py I see there's two : teams1 and teams2. I see the "LA Rams" were added to team2 as the only entry. Should I add LAC there?

This is also very odd, I seem to be able to generate the correct schedule for week 2... but not for week 1...?

Regular 2017 week 1 on 09/11 at 10:20PM, UNK (21) at DEN (24)
Regular 2017 week 2 on 09/17 at 04:05PM, MIA (0) at LAC (0)

Is this something where nflgame or nfldb has already input the week 1 data as UNK and is only updating for week 2?

@ochawkeye
Copy link
Contributor

ochawkeye commented Sep 14, 2017

nfldb-update script, by default, only updates schedules for current week: https://github.com/BurntSushi/nfldb/blob/master/scripts/nfldb-update#L25

For these debugging steps, I used the following code which prints out the game information for each of the Chargers first three opponents in 2017.

import nfldb
db = nfldb.connect()
q = nfldb.Query(db)
q.game(season_year=2017, week=1, team='DEN', season_type='Regular')
for game in q.as_games():
    print game
q = nfldb.Query(db)
q.game(season_year=2017, week=2, team='MIA', season_type='Regular')
for game in q.as_games():
    print game
q = nfldb.Query(db)
q.game(season_year=2017, week=3, team='KC', season_type='Regular')
for game in q.as_games():
    print game
  1. Ran above code (had not modified nfldb\team.py from shipping version)
Regular 2017 week 1 on 09/11 at 09:20PM, UNK (21) at DEN (24)
Regular 2017 week 2 on 09/17 at 03:05PM, MIA (0) at UNK (0)
Regular 2017 week 3 on 09/24 at 03:25PM, KC (0) at UNK (0)
  1. Updated nfldb/team.py with following:
teams2 = [
    ['LA', 'Los Angeles', 'Rams', 'Los Angeles Rams', 'L.A.'],
    ['LAC', 'Los Angeles C', 'Chargers', 'Los Angeles Chargers', 'L.A.C']
]
  1. Ran nfldb-update script.
  2. Re-ran above code
    *Note that week 2 was updated because nfldb-update was performed during week 2.
Regular 2017 week 1 on 09/11 at 09:20PM, UNK (21) at DEN (24)
Regular 2017 week 2 on 09/17 at 03:05PM, MIA (0) at LAC (0)
Regular 2017 week 3 on 09/24 at 03:25PM, KC (0) at UNK (0)
  1. Ran nfldb-update --update-schedules (this took a pretty long time - 7 minutes on my old PC)
  2. Re-ran above code
Regular 2017 week 1 on 09/11 at 09:20PM, LAC (21) at DEN (24)
Regular 2017 week 2 on 09/17 at 03:05PM, MIA (0) at LAC (0)
Regular 2017 week 3 on 09/24 at 03:25PM, KC (0) at LAC (0)

@kennysushi
Copy link

As always @ochawkeye, thank you for your help: specifically calling the --update-schedules fixed this issue.

Regular 2017 week 1 on 09/11 at 10:20PM, LAC (21) at DEN (24)

@joeycortez42
Copy link

@ochawkeye's team.py fix worked for me, but since I had already update nfldb LAC players were showing as UKN. I had to remove the LAC games and rerun nfldb-update.

DELETE FROM game WHERE home_team = 'LAC' OR away_team = 'LAC'

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

No branches or pull requests

5 participants