remove state column

This commit is contained in:
filifa 2024-08-04 16:00:48 -05:00
parent 8654bb13c3
commit ddf5d7f34f
6 changed files with 9 additions and 10 deletions

View File

@ -29,7 +29,7 @@ then
exit 1 exit 1
fi fi
jqFilter='.dates[].games[] | "\(.gamePk)\(.status.detailedState)\(.)"' jqFilter='.dates[].games[] | "\(.gamePk)\(.)"'
fmt="OFS=\"\"; print \$1, \"$team\", \$2, \$3, 0" fmt="OFS=\"\"; print \$1, \"$team\", \$2, 0"
save="\"sqlite3 $db '.mode ascii' '.separator ' '.import /dev/stdin games'\"" save="\"sqlite3 $db '.mode ascii' '.separator ' '.import /dev/stdin games'\""
mlblive schedule -t $team | jq -r "$jqFilter" | awk -F  "{$fmt | $save; close($save)}" mlblive schedule -t $team | jq -r "$jqFilter" | awk -F  "{$fmt | $save; close($save)}"

View File

@ -32,7 +32,7 @@ fi
# grab the game pk of a single live game, if multiple (in case of spring # grab the game pk of a single live game, if multiple (in case of spring
# training) # 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" ]] if [[ -z "$gamePk" ]]
then then
echo "$0:" 'no live games found' >&2 echo "$0:" 'no live games found' >&2

View File

@ -32,7 +32,7 @@ fi
# grab the game pk of a single live game, if multiple (in case of spring # grab the game pk of a single live game, if multiple (in case of spring
# training) # 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" ]] if [[ -z "$gamePk" ]]
then then
echo "$0:" 'no live games found' >&2 echo "$0:" 'no live games found' >&2

View File

@ -8,12 +8,12 @@ json ->> 'teams' ->> 'home' ->> 'team' ->> 'name',
json ->> 'teams' ->> 'home' ->> 'score' json ->> 'teams' ->> 'home' ->> 'score'
from games from games
where where
state = 'Final' and json ->> 'status' ->> 'detailedState' = 'Final' and
posted = 0; posted = 0;
update games update games
set posted = 1 set posted = 1
where where
state = 'Final' and json ->> 'status' ->> 'detailedState' = 'Final' and
posted = 0; posted = 0;
commit; commit;

View File

@ -10,12 +10,12 @@ json ->> 'teams' ->> 'home' ->> 'leagueRecord' ->> 'wins',
json ->> 'teams' ->> 'home' ->> 'leagueRecord' ->> 'losses' json ->> 'teams' ->> 'home' ->> 'leagueRecord' ->> 'losses'
from games from games
where where
state = 'Warmup' and json ->> 'status' ->> 'detailedState' = 'Warmup' and
posted = 0; posted = 0;
update games update games
set posted = 1 set posted = 1
where where
state = 'Warmup' and json ->> 'status' ->> 'detailedState' = 'Warmup' and
posted = 0; posted = 0;
commit; commit;

View File

@ -19,7 +19,6 @@ where posted = 0;
create table if not exists games ( create table if not exists games (
gamePk integer, gamePk integer,
teamId text, teamId text,
state text,
json text, json text,
posted integer, posted integer,
unique (teamId, gamePk) on conflict ignore unique (teamId, gamePk) on conflict ignore
@ -31,5 +30,5 @@ begin
delete from games delete from games
where gamePk = new.gamePk and where gamePk = new.gamePk and
teamId = new.teamId and teamId = new.teamId and
state != new.state; json ->> 'status' ->> 'detailedState' != new.json ->> 'status' ->> 'detailedState';
end; end;