Merge branch 'onedb'
This commit is contained in:
commit
5015924d19
|
@ -42,4 +42,4 @@ fi
|
||||||
# grab select data from response with jq, add 0 to the end of each line (to go
|
# grab select data from response with jq, add 0 to the end of each line (to go
|
||||||
# in the 'posted' db column), then write each line to db
|
# in the 'posted' db column), then write each line to db
|
||||||
jqFilter='.highlights.highlights.items | map(select(.keywordsAll[].value == "highlight"))[] | {headline, id} + {url: (.playbacks | map(select(.name == "mp4Avc"))[0].url)} | select(.url | startswith("https://mlb-cuts-diamond"))'
|
jqFilter='.highlights.highlights.items | map(select(.keywordsAll[].value == "highlight"))[] | {headline, id} + {url: (.playbacks | map(select(.name == "mp4Avc"))[0].url)} | select(.url | startswith("https://mlb-cuts-diamond"))'
|
||||||
mlblive content -g $gamePk | jq -Sc "$jqFilter" | sed 's/$/0/' | sqlite3 $db '.mode ascii' '.separator \n' '.import /dev/stdin mlbdata'
|
mlblive content -g $gamePk | jq -Sc "$jqFilter" | sed 's/$/0/' | sqlite3 $db '.mode ascii' '.separator \n' '.import /dev/stdin highlights'
|
||||||
|
|
|
@ -42,7 +42,7 @@ 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})))'
|
||||||
|
|
||||||
fmt='OFS=""; print $0, 0'
|
fmt='OFS=""; print $0, 0'
|
||||||
save="\"sqlite3 $db '.mode ascii' '.separator ' '.import /dev/stdin mlbdata'\""
|
save="\"sqlite3 $db '.mode ascii' '.separator ' '.import /dev/stdin plays'\""
|
||||||
|
|
||||||
# grab select data from each response with jq, add 0 to the end of each line
|
# grab select data from each response with jq, add 0 to the end of each line
|
||||||
# (to go in the 'posted' db column), then write each line as they come in to db
|
# (to go in the 'posted' db column), then write each line as they come in to db
|
||||||
|
|
|
@ -5,12 +5,12 @@ select
|
||||||
json ->> 'headline',
|
json ->> 'headline',
|
||||||
json ->> 'id',
|
json ->> 'id',
|
||||||
json ->> 'url'
|
json ->> 'url'
|
||||||
from mlbdata
|
from highlights
|
||||||
where
|
where
|
||||||
json ->> 'url' is not null and
|
json ->> 'url' is not null and
|
||||||
posted = 0;
|
posted = 0;
|
||||||
|
|
||||||
update mlbdata
|
update highlights
|
||||||
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 mlbdata
|
from plays
|
||||||
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 mlbdata
|
update plays
|
||||||
set posted = 1
|
set posted = 1
|
||||||
where posted = 0;
|
where posted = 0;
|
||||||
commit;
|
commit;
|
||||||
|
|
15
schema.sql
15
schema.sql
|
@ -1,10 +1,19 @@
|
||||||
create table if not exists mlbdata (
|
create table if not exists plays (
|
||||||
"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
|
create index if not exists nonposted_plays
|
||||||
on mlbdata(posted)
|
on plays(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;
|
||||||
|
|
||||||
create table if not exists games (
|
create table if not exists games (
|
||||||
|
|
Loading…
Reference in New Issue