From d33dd701c30e2845f4da9a604d24cf23a5dd9c5c Mon Sep 17 00:00:00 2001 From: Dave Lawrence Date: Thu, 7 Nov 2013 15:01:04 -0500 Subject: Bug 936049 - MyDashboard display of last change for a bug no longer working due to API change for Bug.history --- extensions/MyDashboard/lib/WebService.pm | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'extensions/MyDashboard') diff --git a/extensions/MyDashboard/lib/WebService.pm b/extensions/MyDashboard/lib/WebService.pm index 6c8879657..a43aa97ab 100644 --- a/extensions/MyDashboard/lib/WebService.pm +++ b/extensions/MyDashboard/lib/WebService.pm @@ -13,7 +13,7 @@ use base qw(Bugzilla::WebService Bugzilla::WebService::Bug); use Bugzilla::Constants; use Bugzilla::Error; -use Bugzilla::Util qw(detaint_natural trick_taint template_var); +use Bugzilla::Util qw(detaint_natural trick_taint template_var datetime_from); use Bugzilla::WebService::Util qw(validate); use Bugzilla::Extension::MyDashboard::Queries qw(QUERY_DEFS query_bugs query_flags); @@ -41,8 +41,12 @@ sub run_bug_query { # Add last changes to each bug foreach my $b (@$bugs) { my $last_changes = {}; - my $activity = $self->history({ ids => [ $b->{bug_id} ], - new_since => $b->{changeddate} }); + # Remove one second so we get the changes made at $change_date (>=) + my $changed_date = datetime_from($b->{changeddate}); + next if !$changed_date; + $changed_date->subtract(seconds => 1); + my $activity = $self->history({ ids => [ $b->{bug_id} ], + new_since => $changed_date }); if (@{$activity->{bugs}[0]{history}}) { my $change_set = $activity->{bugs}[0]{history}[0]; $last_changes->{activity} = $change_set->{changes}; @@ -55,8 +59,8 @@ sub run_bug_query { } my $last_comment_id = $dbh->selectrow_array(" SELECT comment_id FROM longdescs - WHERE bug_id = ? AND bug_when >= ?", - undef, $b->{bug_id}, $b->{changeddate}); + WHERE bug_id = ? AND bug_when > ?", + undef, $b->{bug_id}, $changed_date); if ($last_comment_id) { my $comments = $self->comments({ comment_ids => [ $last_comment_id ] }); my $comment = $comments->{comments}{$last_comment_id}; -- cgit v1.2.3-24-g4f1b