Cleanup - centralize the log handling

This commit is contained in:
2024-08-27 12:16:01 -05:00
parent d8891ec75f
commit a6b7fc7afe
15 changed files with 124 additions and 180 deletions

View File

@@ -1,5 +1,6 @@
#!/bin/bash
#set -x
. helpers.sh
IFS=$'\0'
daysOutMin=90
@@ -9,19 +10,16 @@ inputFile="$1"
latestFile="$1"
if [[ "" == "$inputFile" ]]; then
latestFile="$(ls data/`date +%Y-%m-%d`/*SPY* | sort | tail -n 1)"
systemd-cat -t "`basename $0` $1" -p debug <<< "Latest File: _${latestFile}_"
log "Latest File: _${latestFile}_" debug
inputFile=temp/orderInputFile.json
bzip2 -dc < "${latestFile}" > "${inputFile}"
fi
if [[ ! -f "${inputFile}" ]]; then
errMsg="ERROR: Input file _${inputFile}_ does not exist."
systemd-cat -t "`basename $0` $1" -p err <<< ${errMsg}
>&2 echo "${errMsg}"
exit 1
throw "ERROR: Input file _${inputFile}_ does not exist." err 1
fi
dateKey=$(jq -r '.callExpDateMap | keys | .[]' temp/orderInputFile.json | sort -r -t ":" +2 | awk -F ":" -e '{theDay=$2; if (theDay < '${daysOutMin}') { print lastDay; exit; } else { lastDay=$0; } }')
systemd-cat -t "`basename $0` $1" -p debug <<< "Date-Key: _${dateKey}_"
log "Date-Key: _${dateKey}_" debug
daysOut=$(cut -d : -f 2 <<< ${dateKey})
if [[ ${daysOut} -gt ${daysOutMax} ]]; then