Mercurial > hg > egg-tcls
changeset 466:a8eb80bbffa5
quotedb: Add 'stats' command.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 09 May 2018 20:04:13 +0300 |
parents | ba7ed8f6d2ab |
children | b29b0db02649 |
files | quotedb.tcl |
diffstat | 1 files changed, 18 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/quotedb.tcl Thu Feb 22 20:15:20 2018 +0200 +++ b/quotedb.tcl Wed May 09 20:04:13 2018 +0300 @@ -317,6 +317,21 @@ #------------------------------------------------------------------------- +proc qdb_stats {ucmd utable unick uchan upublic} { + global qdb_handle + + set usql "SELECT count(*) AS nvotes FROM ${utable}_votes" + qdb_handle eval $usql {} + + set usql "SELECT count(*) AS nquotes FROM ${utable}" + qdb_handle eval $usql {} + + qdb_msg $upublic $unick $uchan "${utable}-tilastot: ${nquotes} quotea, ${nvotes} annettua ääntä." + return 0 +} + + +#------------------------------------------------------------------------- proc qdb_find {ucmd utable unick uhand uchan utext upublic} { global qdb_handle qdb_showmax_pub qdb_showmax_priv qdb_msg_no_matches qdb_msg_search_fmt @@ -382,6 +397,9 @@ if {$utext == "" || $utext == {}} { # No arguments, assume random query qdb_get $ucmd $utable $unick $uchan -1 $upublic + } elseif {[regexp {^(stat|stats|tilasto|tilastot)$} $utext umatch]} { + # Statistics + qdb_stats $ucmd $utable $unick $uchan $upublic } elseif {[regexp {^(last|latest|uusin|viimeisin)$} $utext umatch]} { # Latest added qdb_get $ucmd $utable $unick $uchan -2 $upublic