Mercurial > hg > egg-tcls
comparison quotedb.tcl @ 519:1cfa567f9500
quotedb: Improve statistics.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 02 May 2020 15:29:03 +0300 |
parents | 7fdc069840cc |
children | 3046ee0e574d |
comparison
equal
deleted
inserted
replaced
518:7fdc069840cc | 519:1cfa567f9500 |
---|---|
367 qdb_handle eval $usql {} | 367 qdb_handle eval $usql {} |
368 | 368 |
369 set nmaxtop 5 | 369 set nmaxtop 5 |
370 | 370 |
371 set usql "SELECT user,count(*) AS uquotes FROM ${utable} GROUP BY user ORDER BY uquotes DESC LIMIT ${nmaxtop}" | 371 set usql "SELECT user,count(*) AS uquotes FROM ${utable} GROUP BY user ORDER BY uquotes DESC LIMIT ${nmaxtop}" |
372 set ntop {} | 372 set ltopusers {} |
373 set nindex 0 | 373 set ntopusers 0 |
374 qdb_handle eval $usql { | 374 qdb_handle eval $usql { |
375 incr nindex | 375 incr ntopusers |
376 lappend ntop "${user} (${uquotes})" | 376 lappend ltopusers "${user} (${uquotes})" |
377 } | 377 } |
378 | 378 |
379 qdb_msg $ucmd $utable $upublic $unick $uchan "stats" [list $nquotes $nvotes $nindex [join $ntop ", "]] | 379 set nmaxtop 3 |
380 | |
381 set usql "SELECT count(*) AS uquotes,CAST(strftime('%Y',utime,'unixepoch') AS integer) AS uyear FROM ${utable} GROUP BY uyear ORDER BY uyear DESC LIMIT ${nmaxtop}" | |
382 set llatestyears {} | |
383 set nlatestyears 0 | |
384 qdb_handle eval $usql { | |
385 incr nlatestyears | |
386 lappend llatestyears "${uquotes} (${uyear})" | |
387 } | |
388 | |
389 set usql "SELECT count(*) AS uquotes,CAST(strftime('%Y',utime,'unixepoch') AS integer) AS uyear FROM ${utable} GROUP BY uyear ORDER BY uquotes DESC LIMIT ${nmaxtop}" | |
390 set ltopeyears {} | |
391 set ntopyears 0 | |
392 qdb_handle eval $usql { | |
393 incr ntopyears | |
394 lappend ltopeyears "${uquotes} (${uyear})" | |
395 } | |
396 | |
397 qdb_msg $ucmd $utable $upublic $unick $uchan "stats" [list $nquotes $nvotes] | |
398 qdb_msg $ucmd $utable $upublic $unick $uchan "stats2" [list $ntopusers [join $ltopusers ", "] $nlatestyears [join $llatestyears ", "] $ntopyears [join $ltopeyears ", "]] | |
380 | 399 |
381 return 0 | 400 return 0 |
382 } | 401 } |
383 | 402 |
384 | 403 |