From 6abbd9dea1d47ef9a4659ac948eeb5120d0da11c Mon Sep 17 00:00:00 2001 From: Dylan Hardison Date: Thu, 10 Dec 2015 15:23:57 -0500 Subject: Bug 1169181 - The bug_user_last_visit method returns an empty array for old bugs r=dkl --- Bugzilla/WebService/BugUserLastVisit.pm | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'Bugzilla/WebService') diff --git a/Bugzilla/WebService/BugUserLastVisit.pm b/Bugzilla/WebService/BugUserLastVisit.pm index 19a56ff46..3ee8cac03 100644 --- a/Bugzilla/WebService/BugUserLastVisit.pm +++ b/Bugzilla/WebService/BugUserLastVisit.pm @@ -67,27 +67,23 @@ sub get { $user->login(LOGIN_REQUIRED); + my @last_visits; if ($ids) { # Cache permissions for bugs. This highly reduces the number of calls to # the DB. visible_bugs() is only able to handle bug IDs, so we have to # skip aliases. $user->visible_bugs([grep /^[0-9]$/, @$ids]); - } - - my @last_visits = @{ $user->last_visited }; - if ($ids) { - # remove bugs that we are not interested in if ids is passed in. - my %id_set = map { ($_ => 1) } @$ids; - @last_visits = grep { $id_set{ $_->bug_id } } @last_visits; + my %last_visit = map { $_->bug_id => $_->last_visit_ts } @{ $user->last_visited($ids) }; + @last_visits = map { $self->_bug_user_last_visit_to_hash($_, $last_visit{$_}, $params) } @$ids; + } + else { + @last_visits = map { + $self->_bug_user_last_visit_to_hash($_->bug_id, $_->last_visit_ts, $params) + } @{ $user->last_visited }; } - return [ - map { - $self->_bug_user_last_visit_to_hash($_->bug_id, $_->last_visit_ts, - $params) - } @last_visits - ]; + return \@last_visits; } sub _bug_user_last_visit_to_hash { -- cgit v1.2.3-24-g4f1b