From 8ec8da0491ad89604700b3e29a227966f6d84ba1 Mon Sep 17 00:00:00 2001 From: Perl Tidy Date: Wed, 5 Dec 2018 15:38:52 -0500 Subject: no bug - reformat all the code using the new perltidy rules --- Bugzilla/Elastic.pm | 68 ++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 35 deletions(-) (limited to 'Bugzilla/Elastic.pm') 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; -- cgit v1.2.3-24-g4f1b