diff --git a/postplays.sql b/postplays.sql index 4b72e93..42fe877 100644 --- a/postplays.sql +++ b/postplays.sql @@ -9,7 +9,7 @@ json ->> 'awayTeam', json ->> 'awayScore', json ->> 'homeTeam', json ->> 'homeScore' -from playinfo +from plays where json ->> 'description' is not null and json ->> 'isScoringPlay' = 1 and diff --git a/schema.sql b/schema.sql index c3501c6..08e7c02 100644 --- a/schema.sql +++ b/schema.sql @@ -1,10 +1,10 @@ -create table if not exists playinfo ( +create table if not exists plays ( "json" text unique on conflict ignore, "posted" integer check ("posted" in (0, 1)) ); -create index if not exists nonposted_playinfo -on playinfo(posted) +create index if not exists nonposted_plays +on plays(posted) where posted = 0; create table if not exists highlights ( diff --git a/subscribe.sh b/subscribe.sh index fa26511..ab9c103 100755 --- a/subscribe.sh +++ b/subscribe.sh @@ -36,4 +36,4 @@ then fi jqFilter='{gamePk} + (.gameData.teams | {awayTeam: .away.teamName, homeTeam: .home.teamName}) + (.liveData.plays.allPlays[] | (.result + (.about | {atBatIndex, halfInning, inning, isComplete, isScoringPlay, hasReview})))' -mlblive subscribe -g $gamePk | jq -Sc --unbuffered "$jqFilter" | sed -u 's/$/0/' | writedb.sh -d $db -t playinfo -c '' +mlblive subscribe -g $gamePk | jq -Sc --unbuffered "$jqFilter" | sed -u 's/$/0/' | writedb.sh -d $db -t plays -c ''