remove team arg
This commit is contained in:
parent
ddf5d7f34f
commit
62c429dafb
|
@ -30,6 +30,6 @@ then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
jqFilter='.dates[].games[] | "\(.gamePk)\(.)"'
|
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'\""
|
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)}"
|
||||||
|
|
|
@ -9,9 +9,6 @@ do
|
||||||
d)
|
d)
|
||||||
db=$OPTARG
|
db=$OPTARG
|
||||||
;;
|
;;
|
||||||
t)
|
|
||||||
team=$OPTARG
|
|
||||||
;;
|
|
||||||
?)
|
?)
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
@ -24,15 +21,9 @@ then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
# 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 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" ]]
|
if [[ -z "$gamePk" ]]
|
||||||
then
|
then
|
||||||
echo "$0:" 'no live games found' >&2
|
echo "$0:" 'no live games found' >&2
|
||||||
|
|
|
@ -3,15 +3,12 @@
|
||||||
set -e
|
set -e
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
while getopts 'd:t:' opt
|
while getopts 'd:' opt
|
||||||
do
|
do
|
||||||
case $opt in
|
case $opt in
|
||||||
d)
|
d)
|
||||||
db=$OPTARG
|
db=$OPTARG
|
||||||
;;
|
;;
|
||||||
t)
|
|
||||||
team=$OPTARG
|
|
||||||
;;
|
|
||||||
?)
|
?)
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
@ -24,15 +21,9 @@ then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
# 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 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" ]]
|
if [[ -z "$gamePk" ]]
|
||||||
then
|
then
|
||||||
echo "$0:" 'no live games found' >&2
|
echo "$0:" 'no live games found' >&2
|
||||||
|
|
|
@ -18,10 +18,9 @@ where posted = 0;
|
||||||
|
|
||||||
create table if not exists games (
|
create table if not exists games (
|
||||||
gamePk integer,
|
gamePk integer,
|
||||||
teamId text,
|
|
||||||
json text,
|
json text,
|
||||||
posted integer,
|
posted integer,
|
||||||
unique (teamId, gamePk) on conflict ignore
|
unique (gamePk) on conflict ignore
|
||||||
);
|
);
|
||||||
|
|
||||||
create trigger if not exists delete_old_states
|
create trigger if not exists delete_old_states
|
||||||
|
@ -29,6 +28,5 @@ before insert on games
|
||||||
begin
|
begin
|
||||||
delete from games
|
delete from games
|
||||||
where gamePk = new.gamePk and
|
where gamePk = new.gamePk and
|
||||||
teamId = new.teamId and
|
|
||||||
json ->> 'status' ->> 'detailedState' != new.json ->> 'status' ->> 'detailedState';
|
json ->> 'status' ->> 'detailedState' != new.json ->> 'status' ->> 'detailedState';
|
||||||
end;
|
end;
|
||||||
|
|
Loading…
Reference in New Issue