comparison quotedb.tcl @ 466:a8eb80bbffa5

quotedb: Add 'stats' command.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 09 May 2018 20:04:13 +0300
parents ba7ed8f6d2ab
children 32f0aba3ab9b
comparison
equal deleted inserted replaced
465:ba7ed8f6d2ab 466:a8eb80bbffa5
315 return 0 315 return 0
316 } 316 }
317 317
318 318
319 #------------------------------------------------------------------------- 319 #-------------------------------------------------------------------------
320 proc qdb_stats {ucmd utable unick uchan upublic} {
321 global qdb_handle
322
323 set usql "SELECT count(*) AS nvotes FROM ${utable}_votes"
324 qdb_handle eval $usql {}
325
326 set usql "SELECT count(*) AS nquotes FROM ${utable}"
327 qdb_handle eval $usql {}
328
329 qdb_msg $upublic $unick $uchan "${utable}-tilastot: ${nquotes} quotea, ${nvotes} annettua ääntä."
330 return 0
331 }
332
333
334 #-------------------------------------------------------------------------
320 proc qdb_find {ucmd utable unick uhand uchan utext upublic} { 335 proc qdb_find {ucmd utable unick uhand uchan utext upublic} {
321 global qdb_handle qdb_showmax_pub qdb_showmax_priv qdb_msg_no_matches qdb_msg_search_fmt 336 global qdb_handle qdb_showmax_pub qdb_showmax_priv qdb_msg_no_matches qdb_msg_search_fmt
322 337
323 if {$upublic == 0} { 338 if {$upublic == 0} {
324 set ulimit $qdb_showmax_priv 339 set ulimit $qdb_showmax_priv
380 set utext [string trim $utext] 395 set utext [string trim $utext]
381 396
382 if {$utext == "" || $utext == {}} { 397 if {$utext == "" || $utext == {}} {
383 # No arguments, assume random query 398 # No arguments, assume random query
384 qdb_get $ucmd $utable $unick $uchan -1 $upublic 399 qdb_get $ucmd $utable $unick $uchan -1 $upublic
400 } elseif {[regexp {^(stat|stats|tilasto|tilastot)$} $utext umatch]} {
401 # Statistics
402 qdb_stats $ucmd $utable $unick $uchan $upublic
385 } elseif {[regexp {^(last|latest|uusin|viimeisin)$} $utext umatch]} { 403 } elseif {[regexp {^(last|latest|uusin|viimeisin)$} $utext umatch]} {
386 # Latest added 404 # Latest added
387 qdb_get $ucmd $utable $unick $uchan -2 $upublic 405 qdb_get $ucmd $utable $unick $uchan -2 $upublic
388 } elseif {[regexp {^([0-9]+)$} $utext umatch unum]} { 406 } elseif {[regexp {^([0-9]+)$} $utext umatch unum]} {
389 # Numeric argument, assume index query 407 # Numeric argument, assume index query