summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Elastic.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla/Elastic.pm')
-rw-r--r--Bugzilla/Elastic.pm68
1 files changed, 33 insertions, 35 deletions
diff --git a/Bugzilla/Elastic.pm b/Bugzilla/Elastic.pm
index a01d1be42..805094f03 100644
--- a/Bugzilla/Elastic.pm
+++ b/Bugzilla/Elastic.pm
@@ -14,44 +14,42 @@ use Bugzilla::Util qw(trick_taint);
with 'Bugzilla::Elastic::Role::HasClient';
sub suggest_users {
- my ($self, $text) = @_;
-
- unless (Bugzilla->params->{elasticsearch}) {
- # optimization: faster than a regular method call.
- goto &_suggest_users_fallback;
- }
-
- my $field = 'suggest_user';
- if ($text =~ /^:(.+)$/) {
- $text = $1;
- $field = 'suggest_nick';
- }
-
- my $result = eval {
- $self->client->suggest(
- index => Bugzilla::User->ES_INDEX,
- body => {
- $field => {
- text => $text,
- completion => { field => $field, size => 25 },
- }
- }
- );
- };
- if (defined $result) {
- return [ map { $_->{payload} } @{$result->{$field}[0]{options}} ];
- }
- else {
- warn "suggest_users error: $@";
- # optimization: faster than a regular method call.
- goto &_suggest_users_fallback;
- }
+ my ($self, $text) = @_;
+
+ unless (Bugzilla->params->{elasticsearch}) {
+
+ # optimization: faster than a regular method call.
+ goto &_suggest_users_fallback;
+ }
+
+ my $field = 'suggest_user';
+ if ($text =~ /^:(.+)$/) {
+ $text = $1;
+ $field = 'suggest_nick';
+ }
+
+ my $result = eval {
+ $self->client->suggest(
+ index => Bugzilla::User->ES_INDEX,
+ body =>
+ {$field => {text => $text, completion => {field => $field, size => 25},}}
+ );
+ };
+ if (defined $result) {
+ return [map { $_->{payload} } @{$result->{$field}[0]{options}}];
+ }
+ else {
+ warn "suggest_users error: $@";
+
+ # optimization: faster than a regular method call.
+ goto &_suggest_users_fallback;
+ }
}
sub _suggest_users_fallback {
- my ($self, $text) = @_;
- my $users = Bugzilla::User::match($text, 25, 1);
- return [ map { { real_name => $_->name, name => $_->login } } @$users];
+ my ($self, $text) = @_;
+ my $users = Bugzilla::User::match($text, 25, 1);
+ return [map { {real_name => $_->name, name => $_->login} } @$users];
}
1;