From 248a7d4a9604f01df058dd2427897ce7c8f95635 Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Thu, 6 Jul 2017 10:13:48 -0700 Subject: Bug 1377596 - Add changed column to elasticsearch results --- Bugzilla/Elastic/Search.pm | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'Bugzilla') diff --git a/Bugzilla/Elastic/Search.pm b/Bugzilla/Elastic/Search.pm index 24e2e3234..e1af91032 100644 --- a/Bugzilla/Elastic/Search.pm +++ b/Bugzilla/Elastic/Search.pm @@ -76,6 +76,17 @@ sub _arrayref_of_fields { } } + +# Future maintainer: Maybe consider removing "changeddate" from the codebase entirely. +# At some point, bugzilla tried to rename some fields +# one of these is "delta_ts" to changeddate. +# But the DB column stayed the same... and elasticsearch uses the db name +# However search likes to use the "new" name. +# for now we hack a fix in here. +my %REMAP_NAME = ( + changeddate => 'delta_ts', +); + sub data { my ($self) = @_; my $body = $self->es_query; @@ -86,12 +97,11 @@ sub data { body => $body, ); }; - if (!$result) { - die $@; - } + die $@ unless $result; $self->_set_query_time($result->{took} / 1000); + + my @fields = map { $REMAP_NAME{$_} // $_ } @{ $self->fields }; my (@ids, %hits); - my $fields = $self->fields; foreach my $hit (@{ $result->{hits}{hits} }) { push @ids, $hit->{_id}; my $source = $hit->{_source}; @@ -102,7 +112,7 @@ sub data { } trick_taint($hit->{_id}); if ($source) { - $hits{$hit->{_id}} = [ @$source{@$fields} ]; + $hits{$hit->{_id}} = [ @$source{@fields} ]; } else { $hits{$hit->{_id}} = $hit->{_id}; -- cgit v1.2.3-24-g4f1b