use awk to handle locking problem
This commit is contained in:
parent
3a7c644838
commit
e22bf6a6eb
|
@ -38,7 +38,11 @@ then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
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'
|
||||||
|
save="\"sqlite3 $db '.mode ascii' '.separator ' '.import /dev/stdin mlbdata'\""
|
||||||
|
|
||||||
# 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
|
||||||
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" | awk "{$fmt | $save; close($save)}"
|
||||||
mlblive subscribe -g $gamePk | jq -Sc --unbuffered "$jqFilter" | sed -u 's/$/0/' | split -l 1 --filter="sqlite3 $db '.mode ascii' '.separator ' '.import /dev/stdin mlbdata'"
|
|
||||||
|
|
Loading…
Reference in New Issue