# HG changeset patch # User Matti Hamalainen # Date 1525885453 -10800 # Node ID a8eb80bbffa55c47ef98842802f410d5cedcb949 # Parent ba7ed8f6d2abad50aa84ed101d101a51a93c5f69 quotedb: Add 'stats' command. diff -r ba7ed8f6d2ab -r a8eb80bbffa5 quotedb.tcl --- 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