my $ids = $params->{ids};
defined $ids || ThrowCodeError('param_required', { param => 'ids' });
+ my %api_type = (
+ %{{ map { $_ => 'double' } Bugzilla::Bug::NUMERIC_COLUMNS() }},
+ %{{ map { $_ => 'dateTime' } Bugzilla::Bug::DATE_COLUMNS() }},
+ );
my %api_name = reverse %{ Bugzilla::Bug::FIELD_MAP() };
$api_name{'bug_group'} = 'groups';
$bug_history{who} = $self->type('email', $changeset->{who});
$bug_history{changes} = [];
foreach my $change (@{ $changeset->{changes} }) {
- my $api_field = $api_name{$change->{fieldname}} || $change->{fieldname};
+ my $field_name = delete $change->{fieldname};
+ my $api_field_type = $api_type{$field_name} || 'string';
+ my $api_field_name = $api_name{$field_name} || $field_name;
my $attach_id = delete $change->{attachid};
if ($attach_id) {
$change->{attachment_id} = $self->type('int', $attach_id);
}
- $change->{removed} = $self->type('string', $change->{removed});
- $change->{added} = $self->type('string', $change->{added});
- $change->{field_name} = $self->type('string', $api_field);
- delete $change->{fieldname};
+ $change->{removed} = $self->type($api_field_type, $change->{removed});
+ $change->{added} = $self->type($api_field_type, $change->{added});
+ $change->{field_name} = $self->type('string', $api_field_name);
push (@{$bug_history{changes}}, $change);
}
}
sub datetime_format_outbound {
- my $self = shift;
+ my ($self, $value) = @_;
# YUI expects ISO8601 in UTC time; including TZ specifier
- return $self->SUPER::datetime_format_outbound(@_) . 'Z';
+ return $value ? $self->SUPER::datetime_format_outbound($value) . 'Z' : '';
}
sub handle_login {
--- /dev/null
+#!/usr/bin/perl
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
+use 5.10.1;
+use strict;
+use warnings;
+use lib qw(. lib local/lib/perl5);
+
+use Bugzilla;
+use Bugzilla::Field;
+
+my $dbh = Bugzilla->dbh;
+my $resolved_activity = $dbh->selectall_arrayref(
+ 'SELECT id, bug_id, bug_when FROM bugs_activity WHERE fieldid = ? ORDER BY bug_when',
+ undef, get_field_id('cf_last_resolved'));
+my %last_resolved;
+
+foreach my $activity (@$resolved_activity) {
+ my ($id, $bug_id, $added) = @$activity;
+ my $removed = $last_resolved{$bug_id} || '';
+
+ # Copy the `bug_when` column to `added` so it will be UTC instead of PST
+ $dbh->do('UPDATE bugs_activity SET added = ?, removed = ? WHERE id = ?',
+ undef, $added, $removed, $id);
+
+ # Cache the timestamp as a bug can be resolved multiple times
+ $last_resolved{$bug_id} = $added;
+}