Mercurial > hg > egg-tcls
changeset 697:14d4d4300623
quotedb: When searching quotes, inform user if we found more matches than the max matches limit.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 18 Sep 2023 11:20:46 +0300 |
parents | d82cadd5b4ff |
children | 6ba9f961e463 |
files | config.quotedb.example quotedb.tcl |
diffstat | 2 files changed, 7 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/config.quotedb.example Tue Sep 05 00:06:17 2023 +0300 +++ b/config.quotedb.example Mon Sep 18 11:20:46 2023 +0300 @@ -123,6 +123,7 @@ "fmt_get" "#@1@: @2@ (@3@/@4@, @5@)" "fmt_search" "#@1@: @2@ (@3@/@4@)" + "num_matches" "@name@-haku löysi @1@ tulosta joista max @2@ näytettiin." "no_matches" "@name@-haku ei tuottanut tuloksia." "you_voted" "Äänestit @name@ #@1@ @2@, arvosana nyt @3@"
--- a/quotedb.tcl Tue Sep 05 00:06:17 2023 +0300 +++ b/quotedb.tcl Mon Sep 18 11:20:46 2023 +0300 @@ -440,13 +440,17 @@ ### Query the database and output results set uresults 0 + set usql "SELECT count(*) AS uresults FROM $utable $fquery" + qdb_handle eval $usql {} + set usql "SELECT id AS quoteID, utime AS utime, utext AS utext, user AS uuser FROM $utable $fquery ORDER BY utime DESC LIMIT $ulimit" qdb_handle eval $usql { - incr uresults qdb_msg $ucmd $utable $upublic $unick $uchan "fmt_search" [list $quoteID $utext $uuser [qdb_ctime $utime]] } - if {$uresults == 0} { + if {$uresults > $ulimit} { + qdb_msg $ucmd $utable $upublic $unick $uchan "num_matches" [list $uresults $ulimit] + } elseif {$uresults == 0} { qdb_msg $ucmd $utable $upublic $unick $uchan "no_matches" return 0 }