# HG changeset patch # User Matti Hamalainen # Date 1588279203 -10800 # Node ID 3fc74204dd8be3ae9728863cdfdd5bdf2cb9cdac # Parent 2ca6fda5ba1029892bd0d6423fcfef217de746c8 quotedb: Add new information in statistics sub-command. diff -r 2ca6fda5ba10 -r 3fc74204dd8b config.quotedb.example --- a/config.quotedb.example Thu Apr 30 20:51:33 2020 +0300 +++ b/config.quotedb.example Thu Apr 30 23:40:03 2020 +0300 @@ -80,9 +80,9 @@ set qdb_msg_not_found "%1 #%2 ei löydy, tai se ei kuulu käyttäjälle '%3'." -set qdb_msg_stats "%1-tilastot: %2 quotea, %3 annettua ääntä." +set qdb_msg_stats "%1-tilastot: %2 quotea, %3 annettua ääntä. Top %4 lisääjät: %5" -set qdb_msg_help "%1 |add |update |del |find |vote \[ \[1|-1\]\]|top " +set qdb_msg_help "%1 |add |update |del |find |vote \[ \[1|-1\]\]|top |stats" ### diff -r 2ca6fda5ba10 -r 3fc74204dd8b quotedb.tcl --- a/quotedb.tcl Thu Apr 30 20:51:33 2020 +0300 +++ b/quotedb.tcl Thu Apr 30 23:40:03 2020 +0300 @@ -210,9 +210,10 @@ #------------------------------------------------------------------------- proc qdb_toplist {utable unick uchan unum upublic} { global qdb_handle qdb_msg_toplist_limit qdb_msg_toplist_fmt + global qdb_toplist_min qdb_toplist_max - if {$unum < 2 || $unum > 5} { - qdb_msg $upublic $unick $uchan $qdb_msg_toplist_limit [list 2 5] + if {$unum < $qdb_toplist_min || $unum > $qdb_toplist_max} { + qdb_msg $upublic $unick $uchan $qdb_msg_toplist_limit [list $qdb_toplist_min $qdb_toplist_max] return 0 } @@ -335,7 +336,18 @@ set usql "SELECT count(*) AS nquotes FROM ${utable}" qdb_handle eval $usql {} - qdb_msg $upublic $unick $uchan $qdb_msg_stats [list $utable $nquotes $nvotes] + set nmaxtop 5 + + set usql "SELECT user,count(*) AS uquotes FROM ${utable} GROUP BY user ORDER BY uquotes DESC LIMIT ${nmaxtop}" + set ntop {} + set nindex 0 + qdb_handle eval $usql { + incr nindex + lappend ntop "${user} (${uquotes})" + } + + qdb_msg $upublic $unick $uchan $qdb_msg_stats [list $utable $nquotes $nvotes $nindex [join $ntop ", "]] + return 0 } @@ -354,7 +366,7 @@ qdb_log "$unick/$uhand/$uchan searched $utable: $utext" set ftokens [split $utext " "] - set fpatlist "" + set fpatlist {} foreach ftoken $ftokens { set fprefix [string range $ftoken 0 0] set fpattern [string range $ftoken 1 end]