Mercurial > hg > egg-tcls
comparison quotedb.tcl @ 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 | bd7f06c8a515 |
children | 6ba9f961e463 |
comparison
equal
deleted
inserted
replaced
696:d82cadd5b4ff | 697:14d4d4300623 |
---|---|
438 | 438 |
439 set fquery "WHERE [join $fpatlist " AND "]" | 439 set fquery "WHERE [join $fpatlist " AND "]" |
440 | 440 |
441 ### Query the database and output results | 441 ### Query the database and output results |
442 set uresults 0 | 442 set uresults 0 |
443 set usql "SELECT count(*) AS uresults FROM $utable $fquery" | |
444 qdb_handle eval $usql {} | |
445 | |
443 set usql "SELECT id AS quoteID, utime AS utime, utext AS utext, user AS uuser FROM $utable $fquery ORDER BY utime DESC LIMIT $ulimit" | 446 set usql "SELECT id AS quoteID, utime AS utime, utext AS utext, user AS uuser FROM $utable $fquery ORDER BY utime DESC LIMIT $ulimit" |
444 qdb_handle eval $usql { | 447 qdb_handle eval $usql { |
445 incr uresults | |
446 qdb_msg $ucmd $utable $upublic $unick $uchan "fmt_search" [list $quoteID $utext $uuser [qdb_ctime $utime]] | 448 qdb_msg $ucmd $utable $upublic $unick $uchan "fmt_search" [list $quoteID $utext $uuser [qdb_ctime $utime]] |
447 } | 449 } |
448 | 450 |
449 if {$uresults == 0} { | 451 if {$uresults > $ulimit} { |
452 qdb_msg $ucmd $utable $upublic $unick $uchan "num_matches" [list $uresults $ulimit] | |
453 } elseif {$uresults == 0} { | |
450 qdb_msg $ucmd $utable $upublic $unick $uchan "no_matches" | 454 qdb_msg $ucmd $utable $upublic $unick $uchan "no_matches" |
451 return 0 | 455 return 0 |
452 } | 456 } |
453 return 1 | 457 return 1 |
454 } | 458 } |