ENH: Only add new data to report.
When the last reported values are identical to the current values, do not append the same information (just with a new timestamp) to the report. Instead, just print the last report line. With this, the report action can be scheduled periodically (e.g. via cron) without artificially inflating the report file.
This commit is contained in:
@@ -167,7 +167,7 @@ TODO: Report file updated.
|
|||||||
|
|
||||||
>>> todo.sh report
|
>>> todo.sh report
|
||||||
2009-02-13T04:40:00 5 2
|
2009-02-13T04:40:00 5 2
|
||||||
TODO: Report file updated.
|
TODO: Report file is up-to-date.
|
||||||
|
|
||||||
>>> todo.sh remdup
|
>>> todo.sh remdup
|
||||||
Usage: todo.sh [-fhpantvV] [-d todo_config] action [task_number] [task_description]
|
Usage: todo.sh [-fhpantvV] [-d todo_config] action [task_number] [task_description]
|
||||||
|
|||||||
15
todo.sh
15
todo.sh
@@ -1193,9 +1193,18 @@ note: PRIORITY must be anywhere from A to Z."
|
|||||||
|
|
||||||
TOTAL=$( sed -n '$ =' "$TODO_FILE" )
|
TOTAL=$( sed -n '$ =' "$TODO_FILE" )
|
||||||
TDONE=$( sed -n '$ =' "$DONE_FILE" )
|
TDONE=$( sed -n '$ =' "$DONE_FILE" )
|
||||||
echo "$(date +%Y-%m-%dT%T) ${TOTAL:-0} ${TDONE:-0}" >> "$REPORT_FILE"
|
NEWDATA="${TOTAL:-0} ${TDONE:-0}"
|
||||||
sed -ne '$p' "$REPORT_FILE"
|
LASTREPORT=$(sed -ne '$p' "$REPORT_FILE")
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: Report file updated."
|
LASTDATA=${LASTREPORT#* } # Strip timestamp.
|
||||||
|
if [ "$LASTDATA" = "$NEWDATA" ]; then
|
||||||
|
echo "$LASTREPORT"
|
||||||
|
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: Report file is up-to-date."
|
||||||
|
else
|
||||||
|
NEWREPORT="$(date +%Y-%m-%dT%T) ${NEWDATA}"
|
||||||
|
echo "${NEWREPORT}" >> "$REPORT_FILE"
|
||||||
|
echo "${NEWREPORT}"
|
||||||
|
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: Report file updated."
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
* )
|
* )
|
||||||
|
|||||||
Reference in New Issue
Block a user