Mercurial > hg > egg-tcls
comparison tj.tcl @ 624:e7c88d4e917c
tj: Only get clock once.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 11 Feb 2021 10:02:55 +0200 |
parents | 84a30765baa1 |
children | 5eca657134a5 |
comparison
equal
deleted
inserted
replaced
623:efc0e4919746 | 624:e7c88d4e917c |
---|---|
165 # return [utl_str_map_values [tj_qm $ufmt] [list ]] | 165 # return [utl_str_map_values [tj_qm $ufmt] [list ]] |
166 return [tj_get_tj_str $useconds] | 166 return [tj_get_tj_str $useconds] |
167 } | 167 } |
168 | 168 |
169 | 169 |
170 proc tj_display_tjs {upublic unick uchan uname uid} { | 170 proc tj_display_tjs {upublic unick uchan uname uid uclock} { |
171 set uclock [clock seconds] | 171 |
172 set nresults 0 | 172 set nresults 0 |
173 set usql "SELECT * FROM tj WHERE uuser='[utl_escape $uname]' AND utype=0 AND uid LIKE '[utl_escape $uid]'" | 173 set usql "SELECT * FROM tj WHERE uuser='[utl_escape $uname]' AND utype=0 AND uid LIKE '[utl_escape $uid]'" |
174 tj_dbh eval $usql { | 174 tj_dbh eval $usql { |
175 incr nresults | 175 incr nresults |
176 set ustamp [utl_sql_datetime_to_stamp $utarget] | 176 set ustamp [utl_sql_datetime_to_stamp $utarget] |
201 if {![utl_valid_user $uhand]} { | 201 if {![utl_valid_user $uhand]} { |
202 tj_msg $upublic $unick $uchan "err_invalid_user" [list $uhand] | 202 tj_msg $upublic $unick $uchan "err_invalid_user" [list $uhand] |
203 return 1 | 203 return 1 |
204 } | 204 } |
205 | 205 |
206 set uclock [clock seconds] | |
206 set uhand [tj_correct_handle $uhand] | 207 set uhand [tj_correct_handle $uhand] |
207 set qadmin [matchattr $uhand n] | 208 set qadmin [matchattr $uhand n] |
208 | 209 |
209 # Check and handle arguments | 210 # Check and handle arguments |
210 set rarglist [::textutil::split::splitx $uargs {\s+}] | 211 set rarglist [::textutil::split::splitx $uargs {\s+}] |
389 } | 390 } |
390 } else { | 391 } else { |
391 set uname $uhand | 392 set uname $uhand |
392 } | 393 } |
393 | 394 |
394 set uclock [clock seconds] | |
395 | 395 |
396 set usql "SELECT COUNT(*) FROM tj WHERE uuser='[utl_escape $uname]'" | 396 set usql "SELECT COUNT(*) FROM tj WHERE uuser='[utl_escape $uname]'" |
397 if {[catch {set nitems [tj_dbh onecolumn $usql]} uerrmsg]} { | 397 if {[catch {set nitems [tj_dbh onecolumn $usql]} uerrmsg]} { |
398 tj_msg $upublic $unick $uchan "err_sql" [list $uerrmsg] | 398 tj_msg $upublic $unick $uchan "err_sql" [list $uerrmsg] |
399 tj_log "$uerrmsg on SQL:\n$usql" | 399 tj_log "$uerrmsg on SQL:\n$usql" |
450 if {$uname == ""} { | 450 if {$uname == ""} { |
451 tj_msg $upublic $unick $uchan "err_unknown_user" [list $rcmd] | 451 tj_msg $upublic $unick $uchan "err_unknown_user" [list $rcmd] |
452 return 1 | 452 return 1 |
453 } | 453 } |
454 | 454 |
455 tj_display_tjs $upublic $unick $uchan $uname $uid | 455 tj_display_tjs $upublic $unick $uchan $uname $uid $uclock |
456 } else { | 456 } else { |
457 # !tj [#<id>] [name] | 457 # !tj [#<id>] [name] |
458 set uname $uhand | 458 set uname $uhand |
459 set rindex 0 | 459 set rindex 0 |
460 if {[utl_arg_get $rarglist rindex rarg 0]} { | 460 if {[utl_arg_get $rarglist rindex rarg 0]} { |
470 } | 470 } |
471 } else { | 471 } else { |
472 set uid $tj_default_id | 472 set uid $tj_default_id |
473 } | 473 } |
474 | 474 |
475 tj_display_tjs $upublic $unick $uchan $uname $uid | 475 tj_display_tjs $upublic $unick $uchan $uname $uid $uclock |
476 } | 476 } |
477 | 477 |
478 return 1 | 478 return 1 |
479 } | 479 } |
480 | 480 |