comparison quotedb.tcl @ 683:7897b795480b

quotedb: Use custon qdb_ctime() instead of utl_ctime() for shorter timestamp.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 10 Oct 2021 20:52:20 +0300
parents 09be9264ee79
children 5163d582e396
comparison
equal deleted inserted replaced
682:de6cab61061f 683:7897b795480b
64 # Map constant tokens 64 # Map constant tokens
65 set amsg [string map [list "@cmd@" $acmd] $amsg] 65 set amsg [string map [list "@cmd@" $acmd] $amsg]
66 set amsg [string map [list "@name@" $aname] $amsg] 66 set amsg [string map [list "@name@" $aname] $amsg]
67 67
68 utl_msg_args $qdb_preferredmsg $apublic $anick $achan $amsg $aargs 68 utl_msg_args $qdb_preferredmsg $apublic $anick $achan $amsg $aargs
69 }
70
71
72 proc qdb_ctime {ustamp} {
73 if {$ustamp == "" || $ustamp == "*"} {
74 set ustamp 0
75 }
76 return [clock format $ustamp -format "%d.%m.%Y"]
69 } 77 }
70 78
71 79
72 proc qdb_sql_exec {ucmd utable upublic unick uchan usql} { 80 proc qdb_sql_exec {ucmd utable upublic unick uchan usql} {
73 global qdb_handle 81 global qdb_handle
325 333
326 qdb_handle eval $usql { 334 qdb_handle eval $usql {
327 if {[string range $uquote 0 3] == "img:"} { 335 if {[string range $uquote 0 3] == "img:"} {
328 set uquote "${urlprefix}[string range $uquote 4 end]" 336 set uquote "${urlprefix}[string range $uquote 4 end]"
329 } 337 }
330 qdb_msg $ucmd $utable $upublic $unick $uchan "fmt_get" [list $quoteID $uquote $uuser [utl_ctime $utime] $uvote] 338 qdb_msg $ucmd $utable $upublic $unick $uchan "fmt_get" [list $quoteID $uquote $uuser [qdb_ctime $utime] $uvote]
331 return 1 339 return 1
332 } 340 }
333 341
334 qdb_msg $ucmd $utable $upublic $unick $uchan "quote_does_not_exist" [list $uindex] 342 qdb_msg $ucmd $utable $upublic $unick $uchan "quote_does_not_exist" [list $uindex]
335 return 0 343 return 0
425 ### Query the database and output results 433 ### Query the database and output results
426 set uresults 0 434 set uresults 0
427 set usql "SELECT id AS quoteID, utime AS utime, utext AS utext, user AS uuser FROM $utable $fquery ORDER BY utime DESC LIMIT $ulimit" 435 set usql "SELECT id AS quoteID, utime AS utime, utext AS utext, user AS uuser FROM $utable $fquery ORDER BY utime DESC LIMIT $ulimit"
428 qdb_handle eval $usql { 436 qdb_handle eval $usql {
429 incr uresults 437 incr uresults
430 qdb_msg $ucmd $utable $upublic $unick $uchan "fmt_search" [list $quoteID $utext $uuser [utl_ctime $utime]] 438 qdb_msg $ucmd $utable $upublic $unick $uchan "fmt_search" [list $quoteID $utext $uuser [qdb_ctime $utime]]
431 } 439 }
432 440
433 if {$uresults == 0} { 441 if {$uresults == 0} {
434 qdb_msg $ucmd $utable $upublic $unick $uchan "no_matches" 442 qdb_msg $ucmd $utable $upublic $unick $uchan "no_matches"
435 return 0 443 return 0