From ddf5d7f34f6fa7689154bbe71dbb79a8fbe43443 Mon Sep 17 00:00:00 2001 From: filifa Date: Sun, 4 Aug 2024 16:00:48 -0500 Subject: [PATCH] remove state column --- mlbgames.sh | 4 ++-- mlbhighlightsave.sh | 2 +- mlbplaysave.sh | 2 +- postfinal.sql | 4 ++-- poststart.sql | 4 ++-- schema.sql | 3 +-- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/mlbgames.sh b/mlbgames.sh index c04965d..3351abe 100755 --- a/mlbgames.sh +++ b/mlbgames.sh @@ -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)}" diff --git a/mlbhighlightsave.sh b/mlbhighlightsave.sh index f3fc944..028d014 100755 --- a/mlbhighlightsave.sh +++ b/mlbhighlightsave.sh @@ -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 diff --git a/mlbplaysave.sh b/mlbplaysave.sh index bfa18fb..fed4f44 100755 --- a/mlbplaysave.sh +++ b/mlbplaysave.sh @@ -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 diff --git a/postfinal.sql b/postfinal.sql index 2a83310..20c0f5a 100644 --- a/postfinal.sql +++ b/postfinal.sql @@ -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; diff --git a/poststart.sql b/poststart.sql index 500924e..fa13c5e 100644 --- a/poststart.sql +++ b/poststart.sql @@ -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; diff --git a/schema.sql b/schema.sql index cbeda8a..d161d45 100644 --- a/schema.sql +++ b/schema.sql @@ -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;