summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2017-07-06 19:13:48 +0200
committerDylan William Hardison <dylan@hardison.net>2017-07-07 00:19:39 +0200
commit248a7d4a9604f01df058dd2427897ce7c8f95635 (patch)
tree100a1f0b01c503238e96223de04f8298eac0b0a7 /Bugzilla
parent09e9cbbb2c14f790c9e510c33f5f80e9b7c15b31 (diff)
downloadbugzilla-248a7d4a9604f01df058dd2427897ce7c8f95635.tar.gz
bugzilla-248a7d4a9604f01df058dd2427897ce7c8f95635.tar.xz
Bug 1377596 - Add changed column to elasticsearch results
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Elastic/Search.pm20
1 files changed, 15 insertions, 5 deletions
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};