only make and use one table
This commit is contained in:
parent
78685d43bb
commit
e873ed44b8
|
@ -37,4 +37,4 @@ then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
jqFilter='.highlights.highlights.items | map(select(.keywordsAll[].value == "highlight"))[] | {headline, id} + {url: (.playbacks | map(select(.name == "mp4Avc"))[0].url)}'
|
jqFilter='.highlights.highlights.items | map(select(.keywordsAll[].value == "highlight"))[] | {headline, id} + {url: (.playbacks | map(select(.name == "mp4Avc"))[0].url)}'
|
||||||
mlblive content -g $gamePk | jq -Sc --unbuffered "$jqFilter" | sed -u 's/$/0/' | writedb.sh -d $db -t highlights -c ''
|
mlblive content -g $gamePk | jq -Sc --unbuffered "$jqFilter" | sed -u 's/$/0/' | writedb.sh -d $db -t mlbdata -c ''
|
||||||
|
|
|
@ -37,4 +37,4 @@ then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
jqFilter='{gamePk} + (.gameData.teams | {awayTeam: .away.teamName, homeTeam: .home.teamName}) + (.liveData.plays.allPlays[] | (.result + (.about | {atBatIndex, halfInning, inning, isComplete, isScoringPlay, hasReview})))'
|
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 plays -c ''
|
mlblive subscribe -g $gamePk | jq -Sc --unbuffered "$jqFilter" | sed -u 's/$/0/' | writedb.sh -d $db -t mlbdata -c ''
|
||||||
|
|
|
@ -5,12 +5,12 @@ select
|
||||||
json ->> 'headline',
|
json ->> 'headline',
|
||||||
json ->> 'id',
|
json ->> 'id',
|
||||||
json ->> 'url'
|
json ->> 'url'
|
||||||
from highlights
|
from mlbdata
|
||||||
where
|
where
|
||||||
json ->> 'url' is not null and
|
json ->> 'url' is not null and
|
||||||
posted = 0;
|
posted = 0;
|
||||||
|
|
||||||
update highlights
|
update mlbdata
|
||||||
set posted = 1
|
set posted = 1
|
||||||
where posted = 0;
|
where posted = 0;
|
||||||
commit;
|
commit;
|
||||||
|
|
|
@ -9,13 +9,13 @@ json ->> 'awayTeam',
|
||||||
json ->> 'awayScore',
|
json ->> 'awayScore',
|
||||||
json ->> 'homeTeam',
|
json ->> 'homeTeam',
|
||||||
json ->> 'homeScore'
|
json ->> 'homeScore'
|
||||||
from plays
|
from mlbdata
|
||||||
where
|
where
|
||||||
json ->> 'description' is not null and
|
json ->> 'description' is not null and
|
||||||
json ->> 'isScoringPlay' = 1 and
|
json ->> 'isScoringPlay' = 1 and
|
||||||
posted = 0;
|
posted = 0;
|
||||||
|
|
||||||
update plays
|
update mlbdata
|
||||||
set posted = 1
|
set posted = 1
|
||||||
where posted = 0;
|
where posted = 0;
|
||||||
commit;
|
commit;
|
||||||
|
|
15
schema.sql
15
schema.sql
|
@ -1,17 +1,8 @@
|
||||||
create table if not exists plays (
|
create table if not exists mlbdata (
|
||||||
"json" text unique on conflict ignore,
|
"json" text unique on conflict ignore,
|
||||||
"posted" integer check ("posted" in (0, 1))
|
"posted" integer check ("posted" in (0, 1))
|
||||||
);
|
);
|
||||||
|
|
||||||
create index if not exists nonposted_plays
|
create index if not exists nonposted
|
||||||
on plays(posted)
|
on mlbdata(posted)
|
||||||
where posted = 0;
|
|
||||||
|
|
||||||
create table if not exists highlights (
|
|
||||||
"json" text unique on conflict ignore,
|
|
||||||
"posted" integer check ("posted" in (0, 1))
|
|
||||||
);
|
|
||||||
|
|
||||||
create index if not exists nonposted_highlights
|
|
||||||
on highlights(posted)
|
|
||||||
where posted = 0;
|
where posted = 0;
|
||||||
|
|
Loading…
Reference in New Issue