diff options
author | Perl Tidy <perltidy@bugzilla.org> | 2018-12-05 21:38:52 +0100 |
---|---|---|
committer | Dylan William Hardison <dylan@hardison.net> | 2018-12-05 23:49:08 +0100 |
commit | 8ec8da0491ad89604700b3e29a227966f6d84ba1 (patch) | |
tree | 9d270f173330ca19700e0ba9f2ee931300646de1 /Bugzilla/Elastic.pm | |
parent | a7bb5a65b71644d9efce5fed783ed545b9336548 (diff) | |
download | bugzilla-8ec8da0491ad89604700b3e29a227966f6d84ba1.tar.gz bugzilla-8ec8da0491ad89604700b3e29a227966f6d84ba1.tar.xz |
no bug - reformat all the code using the new perltidy rules
Diffstat (limited to 'Bugzilla/Elastic.pm')
-rw-r--r-- | Bugzilla/Elastic.pm | 68 |
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; |