tblancher's timetracker timekeeping system
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
timetracker/do_process

73 lines
1.7 KiB

#!/Users/tblancher/homebrew/bin/bash
declare -A ORGS
#set -x
if [[ "x${1}" == "x" ]]; then
DATE=$(date +%F)
else
DATE=$1
fi
if [[ -f ${DATE}.log ]]; then
find_existing_org () {
for org in ${ORGS[@]}; do
[[ "${org}" == "${1}" ]] && return 0
done
return 1
}
get_list_of_orgs () {
while read; do
org=$( grep -Po "\s+\[.*\]" <<< "${REPLY}" | tr -d '[][]' | xargs )
[[ "${org}x" == "x" ]] && continue
# org="${org##*( )}" # trim leading whitespace
# org="${org%%*( )}" # trim trailing whitespace
# [[ "${ORGS[@]}" =~ "^${org}$" ]] || ORGS+=("${org}")
# find_existing_org "${org}" || ORGS+=("${org}")
ORGS["${org}"]=1
done
}
get_list_of_orgs < ${DATE}.log
# IFS=$'\n'; KEYS=($(sort -f <<< "${!ORGS[@]}")); unset IFS
KEYS=()
while IFS= read -rd '' key; do
KEYS+=( "${key}" )
done < <(printf '%s\0' "${!ORGS[@]}" | sort -f -z)
# for (( i=0; i < ${#ORGS[@]}; i++ )); do
for org in "${KEYS[@]}"; do
echo "[${org}]"
done
# for org in "${!ORGS[@]}"; do
# echo "[${org}]"
# done
echo "--"
echo ${DATE}
echo
echo
echo
WHOLE=""
for pattern in "${KEYS[@]}"; do
#echo "pattern=${pattern}" >&2
grep -- "\[${pattern}\]" ${DATE}.log | timetracker
echo
if [[ "${WHOLE}x" == "x" ]]; then
WHOLE="${pattern}"
else
WHOLE="${WHOLE}|${pattern}"
fi
echo
done
grep -Ev "${WHOLE}" ${DATE}.log | timetracker
echo
timetracker ${DATE}.log | grep "Section" | sed 's/Section/Grand/'
else
echo "${DATE}.log does not exist" >&2
fi
#set +x