Mercurial > hg > egg-tcls
changeset 508:3fc74204dd8b
quotedb: Add new information in statistics sub-command.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 30 Apr 2020 23:40:03 +0300 |
parents | 2ca6fda5ba10 |
children | 0e3d24e02239 |
files | config.quotedb.example quotedb.tcl |
diffstat | 2 files changed, 18 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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 <id>|add <teksti>|update <id> <teksti>|del <id>|find <parametrit>|vote \[<id> \[1|-1\]\]|top <n>" +set qdb_msg_help "%1 <id>|add <teksti>|update <id> <teksti>|del <id>|find <parametrit>|vote \[<id> \[1|-1\]\]|top <n>|stats" ###
--- 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]