From 70548bda025ddc63429fd69ffa73e40a78031fdd Mon Sep 17 00:00:00 2001 From: filifa <filifa.breath652@8alias.com> Date: Fri, 26 Jul 2024 21:42:09 -0500 Subject: [PATCH] write some simple highlight scripts --- mlbposthighlights.sh | 23 +++++++++++++++++++++++ posthighlights.sql | 16 ++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100755 mlbposthighlights.sh create mode 100644 posthighlights.sql diff --git a/mlbposthighlights.sh b/mlbposthighlights.sh new file mode 100755 index 0000000..5ed3fb5 --- /dev/null +++ b/mlbposthighlights.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +set -e + +while getopts 'd:' opt +do + case $opt in + d) + db=$OPTARG + ;; + ?) + exit 1 + ;; + esac +done + +if [[ -z $db ]] +then + echo "$0:" '-d is required' >&2 + exit 1 +fi + +sqlite3 $db < posthighlights.sql | awk -F '{printf "%s\n\n%s\n", $1, $3}' diff --git a/posthighlights.sql b/posthighlights.sql new file mode 100644 index 0000000..f095401 --- /dev/null +++ b/posthighlights.sql @@ -0,0 +1,16 @@ +.separator + +begin; +select +json ->> 'headline', +json ->> 'id', +json ->> 'url' +from highlights +where +json ->> 'url' is not null and +posted = 0; + +update highlights +set posted = 1 +where posted = 0; +commit;