From 62c429dafb06d38bc7f3c7e54ec23bdece56e091 Mon Sep 17 00:00:00 2001 From: filifa Date: Mon, 5 Aug 2024 22:44:18 -0500 Subject: [PATCH] remove team arg --- mlbgames.sh | 2 +- mlbhighlightsave.sh | 11 +---------- mlbplaysave.sh | 13 ++----------- schema.sql | 4 +--- 4 files changed, 5 insertions(+), 25 deletions(-) diff --git a/mlbgames.sh b/mlbgames.sh index 3351abe..2af7628 100755 --- a/mlbgames.sh +++ b/mlbgames.sh @@ -30,6 +30,6 @@ then fi jqFilter='.dates[].games[] | "\(.gamePk)\(.)"' -fmt="OFS=\"\"; print \$1, \"$team\", \$2, 0" +fmt="OFS=\"\"; print \$1, \$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 028d014..3d23911 100755 --- a/mlbhighlightsave.sh +++ b/mlbhighlightsave.sh @@ -9,9 +9,6 @@ do d) db=$OPTARG ;; - t) - team=$OPTARG - ;; ?) exit 1 ;; @@ -24,15 +21,9 @@ then exit 1 fi -if [[ -z $team ]] -then - echo "$0:" '-t is required' >&2 - exit 1 -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 json ->> 'status' ->> 'detailedState' = 'In Progress' limit 1") +gamePk=$(sqlite3 $db "select gamePk from games where 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 fed4f44..396f804 100755 --- a/mlbplaysave.sh +++ b/mlbplaysave.sh @@ -3,15 +3,12 @@ set -e set -o pipefail -while getopts 'd:t:' opt +while getopts 'd:' opt do case $opt in d) db=$OPTARG ;; - t) - team=$OPTARG - ;; ?) exit 1 ;; @@ -24,15 +21,9 @@ then exit 1 fi -if [[ -z $team ]] -then - echo "$0:" '-t is required' >&2 - exit 1 -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 json ->> 'status' ->> 'detailedState' in ('In Progress', 'Warmup') limit 1") +gamePk=$(sqlite3 $db "select gamePk from games where json ->> 'status' ->> 'detailedState' in ('In Progress', 'Warmup') limit 1") if [[ -z "$gamePk" ]] then echo "$0:" 'no live games found' >&2 diff --git a/schema.sql b/schema.sql index d161d45..3cbb5e1 100644 --- a/schema.sql +++ b/schema.sql @@ -18,10 +18,9 @@ where posted = 0; create table if not exists games ( gamePk integer, - teamId text, json text, posted integer, - unique (teamId, gamePk) on conflict ignore + unique (gamePk) on conflict ignore ); create trigger if not exists delete_old_states @@ -29,6 +28,5 @@ before insert on games begin delete from games where gamePk = new.gamePk and - teamId = new.teamId and json ->> 'status' ->> 'detailedState' != new.json ->> 'status' ->> 'detailedState'; end;