зеркало из https://github.com/mozilla/pjs.git
Improve search for edit_users.cgi.
This commit is contained in:
Родитель
8e4cbeff08
Коммит
e128e885bb
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ 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 = {
|
||||
users => $users,
|
||||
|
|
|
@ -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" />
|
||||
|
|
Загрузка…
Ссылка в новой задаче