More verbose script for nfldb-update workaround

This commit is contained in:
Brian Warren 2017-08-25 18:22:45 -05:00
parent 8ad0609f50
commit e3961f03a9
2 changed files with 26 additions and 8 deletions

View File

@ -0,0 +1,26 @@
#!/bin/sh
# This is a workaround for an error that occurs when running 'nfldb-update' where some of the JSON data it
# gets from the internet contains "JAX" instead of "JAC" as the key for the Jacksonville Jaguars team
# Workaround
# Temporarily add a new team with the bad key
psql --username=nfldb nfldb --command="INSERT INTO team VALUES ('JAX', 'Jacksonville', 'Jaguars')"
# Run nfldb-update - shouldn't have the error since it finds a matching team with bad key, "JAX"
nfldb-update
# Check which tables have been populated with the bad key:
psql --username=nfldb nfldb --command="SELECT COUNT(*) FROM play WHERE pos_team = 'JAX'"
psql --username=nfldb nfldb --command="SELECT COUNT(*) FROM drive WHERE pos_team = 'JAX'"
psql --username=nfldb nfldb --command="SELECT COUNT(*) FROM game WHERE home_team = 'JAX'"
psql --username=nfldb nfldb --command="SELECT COUNT(*) FROM game WHERE away_team = 'JAX'"
psql --username=nfldb nfldb --command="SELECT COUNT(*) FROM player WHERE team = 'JAX'"
psql --username=nfldb nfldb --command="SELECT COUNT(*) FROM play_player WHERE team = 'JAX'"
# Fix all the tables where the bad key appears
psql --username=nfldb nfldb --command="UPDATE play SET pos_team = 'JAC' WHERE pos_team = 'JAX'"
# Delete the team with the bad key
psql --username=nfldb nfldb --command="DELETE FROM team WHERE team_id = 'JAX'"

View File

@ -1,8 +0,0 @@
#!/bin/sh
# This is a workaround for an error that occurs when running 'nfldb-update' where some of the JSON data it
# gets from the internet contains "JAX" instead of "JAC" as the key for the Jacksonville Jaguars team
psql --username=nfldb nfldb --command="INSERT INTO team VALUES ('JAX', 'Jacksonville', 'Jaguars')"
nfldb-update
psql --username=nfldb nfldb --command="UPDATE play SET pos_team = 'JAC' WHERE pos_team = 'JAX'"
psql --username=nfldb nfldb --command="DELETE FROM team WHERE team_id = 'JAX'"