remove state column
This commit is contained in:
		
							parent
							
								
									8654bb13c3
								
							
						
					
					
						commit
						ddf5d7f34f
					
				| 
						 | 
				
			
			@ -29,7 +29,7 @@ then
 | 
			
		|||
	exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
jqFilter='.dates[].games[] | "\(.gamePk)\(.status.detailedState)\(.)"'
 | 
			
		||||
fmt="OFS=\"\"; print \$1, \"$team\", \$2, \$3, 0"
 | 
			
		||||
jqFilter='.dates[].games[] | "\(.gamePk)\(.)"'
 | 
			
		||||
fmt="OFS=\"\"; print \$1, \"$team\", \$2, 0"
 | 
			
		||||
save="\"sqlite3 $db '.mode ascii' '.separator ' '.import /dev/stdin games'\""
 | 
			
		||||
mlblive schedule -t $team | jq -r "$jqFilter" | awk -F  "{$fmt | $save; close($save)}"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -32,7 +32,7 @@ fi
 | 
			
		|||
 | 
			
		||||
# grab the game pk of a single live game, if multiple (in case of spring
 | 
			
		||||
# training)
 | 
			
		||||
gamePk=$(sqlite3 $db "select gamePk from games where teamId='$team' and state='In Progress' limit 1")
 | 
			
		||||
gamePk=$(sqlite3 $db "select gamePk from games where teamId='$team' and json ->> 'status' ->> 'detailedState' = 'In Progress' limit 1")
 | 
			
		||||
if [[ -z "$gamePk" ]]
 | 
			
		||||
then
 | 
			
		||||
	echo "$0:" 'no live games found' >&2
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -32,7 +32,7 @@ fi
 | 
			
		|||
 | 
			
		||||
# grab the game pk of a single live game, if multiple (in case of spring
 | 
			
		||||
# training)
 | 
			
		||||
gamePk=$(sqlite3 $db "select gamePk from games where teamId='$team' and state in ('In Progress', 'Warmup') limit 1")
 | 
			
		||||
gamePk=$(sqlite3 $db "select gamePk from games where teamId='$team' and json ->> 'status' ->> 'detailedState' in ('In Progress', 'Warmup') limit 1")
 | 
			
		||||
if [[ -z "$gamePk" ]]
 | 
			
		||||
then
 | 
			
		||||
	echo "$0:" 'no live games found' >&2
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,12 +8,12 @@ json ->> 'teams' ->> 'home' ->> 'team' ->> 'name',
 | 
			
		|||
json ->> 'teams' ->> 'home' ->> 'score'
 | 
			
		||||
from games
 | 
			
		||||
where
 | 
			
		||||
state = 'Final' and
 | 
			
		||||
json ->> 'status' ->> 'detailedState' = 'Final' and
 | 
			
		||||
posted = 0;
 | 
			
		||||
 | 
			
		||||
update games
 | 
			
		||||
set posted = 1
 | 
			
		||||
where
 | 
			
		||||
state = 'Final' and
 | 
			
		||||
json ->> 'status' ->> 'detailedState' = 'Final' and
 | 
			
		||||
posted = 0;
 | 
			
		||||
commit;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,12 +10,12 @@ json ->> 'teams' ->> 'home' ->> 'leagueRecord' ->> 'wins',
 | 
			
		|||
json ->> 'teams' ->> 'home' ->> 'leagueRecord' ->> 'losses'
 | 
			
		||||
from games
 | 
			
		||||
where
 | 
			
		||||
state = 'Warmup' and
 | 
			
		||||
json ->> 'status' ->> 'detailedState' = 'Warmup' and
 | 
			
		||||
posted = 0;
 | 
			
		||||
 | 
			
		||||
update games
 | 
			
		||||
set posted = 1
 | 
			
		||||
where
 | 
			
		||||
state = 'Warmup' and
 | 
			
		||||
json ->> 'status' ->> 'detailedState' = 'Warmup' and
 | 
			
		||||
posted = 0;
 | 
			
		||||
commit;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,7 +19,6 @@ where posted = 0;
 | 
			
		|||
create table if not exists games (
 | 
			
		||||
	gamePk	integer,
 | 
			
		||||
	teamId	text,
 | 
			
		||||
	state	text,
 | 
			
		||||
	json	text,
 | 
			
		||||
	posted	integer,
 | 
			
		||||
	unique (teamId, gamePk) on conflict ignore
 | 
			
		||||
| 
						 | 
				
			
			@ -31,5 +30,5 @@ begin
 | 
			
		|||
	delete from games
 | 
			
		||||
	where gamePk = new.gamePk and
 | 
			
		||||
	teamId = new.teamId and
 | 
			
		||||
	state != new.state;
 | 
			
		||||
	json ->> 'status' ->> 'detailedState' != new.json ->> 'status' ->> 'detailedState';
 | 
			
		||||
end;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue