Mercurial > hg > egg-tcls
diff tj.tcl @ 616:20dba2c757de
tj: Improve output of 'list' command, and make it configurable.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 10 Feb 2021 13:36:31 +0200 |
parents | 1dac9129eb0f |
children | ce7a666991e3 |
line wrap: on
line diff
--- a/tj.tcl Wed Feb 10 12:34:12 2021 +0200 +++ b/tj.tcl Wed Feb 10 13:36:31 2021 +0200 @@ -381,14 +381,23 @@ # !tj list # List reminders set uclock [clock seconds] - set nresults 0 + + set usql "SELECT COUNT(*) FROM tj WHERE uuser='[utl_escape $uhand]'" + if {[catch {set nitems [tj_dbh onecolumn $usql]} uerrmsg]} { + tj_msg $upublic $unick $uchan "err_sql" [list $uerrmsg] + tj_log "$uerrmsg on SQL:\n$usql" + return 1 + } + + set nitem 0 set usql "SELECT * FROM tj WHERE uuser='[utl_escape $uhand]' ORDER BY ucreated" tj_dbh eval $usql { - incr nresults - tj_msg $upublic $unick $uchan "#${nresults}: $utype : $utarget : $uid : $udesc" + incr nitem + set ustamp [utl_sql_datetime_to_stamp $utarget] + tj_msg $upublic $unick $uchan "list_item" [list $nitem $nitems [tj_ctime $ustamp] $uid $udesc] } - if {!$nresults} { + if {!$nitem} { tj_msg $upublic $unick $uchan "no_results" [list $uname] }