Improve search for edit_users.cgi.

This commit is contained in:
zach%zachlipton.com 2006-06-16 18:36:51 +00:00
Родитель 734802cbe0
Коммит 4f55f337d0
7 изменённых файлов: 22 добавлений и 8 удалений

Просмотреть файл

@ -21,6 +21,8 @@ Time::Piece::mysql
Time::Seconds
HTML::StripScripts
HTML::StripScripts::Parser
Text::Markdown
XML::XPath
Once you've got everything installed, run: mysql < createdb.sql to
create the Litmus database.

Просмотреть файл

@ -66,16 +66,20 @@ __PACKAGE__->set_sql(TopTesters => qq{
LIMIT 15
});
# search by email, realname, or irc_nickname
__PACKAGE__->set_sql(FullTextMatches => qq{
SELECT *,
MATCH (email, realname, irc_nickname) AGAINST (?) AS relevance
# the COLLATE latin1_general_ci sillyness forces a case-insensitive match
__PACKAGE__->set_sql(FullTextMatches => q{
SELECT *
FROM __TABLE__
WHERE MATCH (email, realname, irc_nickname) AGAINST (?) HAVING relevance > 0
ORDER BY relevance DESC, user_id ASC
LIMIT 100
WHERE
email COLLATE latin1_general_ci like concat('%%',?,'%%') OR
irc_nickname COLLATE latin1_general_ci like concat('%%',?,'%%') OR
realname COLLATE latin1_general_ci like concat('%%',?,'%%')
ORDER BY email ASC
LIMIT 300
});
#########################################################################
# returns the crypt'd password from a linked Bugzilla account if it
# exists or the Litmus user account

Просмотреть файл

@ -227,6 +227,7 @@ sub DropIndex {
my $ref = $self->GetIndexDef($table, $index);
return unless $ref; # no matching index?
print "Removing index $index from table $table ...\n";
$self->{'dbh'}->do("ALTER TABLE $table
DROP INDEX $index");
}

Просмотреть файл

@ -40,6 +40,7 @@ Litmus::Auth::requireAdmin('edit_users.cgi');
if ($c->param('search_string')) {
# search for users:
my $users = Litmus::DB::User->search_FullTextMatches(
$c->param('search_string'),
$c->param('search_string'),
$c->param('search_string'));
my $vars = {

Просмотреть файл

@ -237,6 +237,10 @@ $dbtool->AddFullText("users", "key", "(email, realname, irc_nickname)");
$dbtool->DropIndex("users", "irc_nickname");
$dbtool->AddKey("users", "irc_nickname", "(irc_nickname)");
# this should be a normal index, not a fulltext index
$dbtool->DropIndex("users", "key(email, realname, irc_nickname)");
$dbtool->AddKey("users", '(email, realname, irc_nickname)', '');
print "Schema update complete.\n\n";
print <<EOS;

Просмотреть файл

@ -350,4 +350,4 @@ $table{users} =
index(realname),
index(enabled),
index(is_admin),
fulltext key(email, realname, irc_nickname)';
index(email, realname, irc_nickname)';

Просмотреть файл

@ -22,6 +22,8 @@
#
#%]
<p>You may search by email address, real name, or irc nickname.</p>
<form action="edit_users.cgi" method="get" name="form" id="form">
List users matching
<input name="search_string" size="35" />