summaryrefslogtreecommitdiffstats
path: root/Bugzilla/WebService/BugUserLastVisit.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla/WebService/BugUserLastVisit.pm')
-rw-r--r--Bugzilla/WebService/BugUserLastVisit.pm118
1 files changed, 59 insertions, 59 deletions
diff --git a/Bugzilla/WebService/BugUserLastVisit.pm b/Bugzilla/WebService/BugUserLastVisit.pm
index 5e4c0d2ba..9b4261bc3 100644
--- a/Bugzilla/WebService/BugUserLastVisit.pm
+++ b/Bugzilla/WebService/BugUserLastVisit.pm
@@ -19,84 +19,84 @@ use Bugzilla::WebService::Util qw( validate filter );
use Bugzilla::Constants;
use constant PUBLIC_METHODS => qw(
- get
- update
+ get
+ update
);
sub update {
- my ($self, $params) = validate(@_, 'ids');
- my $user = Bugzilla->user;
- my $dbh = Bugzilla->dbh;
+ my ($self, $params) = validate(@_, 'ids');
+ my $user = Bugzilla->user;
+ my $dbh = Bugzilla->dbh;
- $user->login(LOGIN_REQUIRED);
+ $user->login(LOGIN_REQUIRED);
- my $ids = $params->{ids} // [];
- ThrowCodeError('param_required', { param => 'ids' }) unless @$ids;
+ my $ids = $params->{ids} // [];
+ ThrowCodeError('param_required', {param => 'ids'}) unless @$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]);
+ # 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]);
- $dbh->bz_start_transaction();
- my @results;
- my $last_visit_ts = $dbh->selectrow_array('SELECT NOW()');
- foreach my $bug_id (@$ids) {
- my $bug = Bugzilla::Bug->check({ id => $bug_id, cache => 1 });
+ $dbh->bz_start_transaction();
+ my @results;
+ my $last_visit_ts = $dbh->selectrow_array('SELECT NOW()');
+ foreach my $bug_id (@$ids) {
+ my $bug = Bugzilla::Bug->check({id => $bug_id, cache => 1});
- ThrowUserError('user_not_involved', { bug_id => $bug->id })
- unless $user->is_involved_in_bug($bug);
+ ThrowUserError('user_not_involved', {bug_id => $bug->id})
+ unless $user->is_involved_in_bug($bug);
- $bug->update_user_last_visit($user, $last_visit_ts);
+ $bug->update_user_last_visit($user, $last_visit_ts);
- push(
- @results,
- $self->_bug_user_last_visit_to_hash(
- $bug_id, $last_visit_ts, $params
- ));
- }
- $dbh->bz_commit_transaction();
+ push(@results,
+ $self->_bug_user_last_visit_to_hash($bug_id, $last_visit_ts, $params));
+ }
+ $dbh->bz_commit_transaction();
- return \@results;
+ return \@results;
}
sub get {
- my ($self, $params) = validate(@_, 'ids');
- my $user = Bugzilla->user;
- my $ids = $params->{ids};
-
- $user->login(LOGIN_REQUIRED);
-
- 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;
- }
-
- return [
- map {
- $self->_bug_user_last_visit_to_hash($_->bug_id, $_->last_visit_ts,
- $params)
- } @last_visits
- ];
+ my ($self, $params) = validate(@_, 'ids');
+ my $user = Bugzilla->user;
+ my $ids = $params->{ids};
+
+ $user->login(LOGIN_REQUIRED);
+
+ 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;
+ }
+
+ return [
+ map {
+ $self->_bug_user_last_visit_to_hash($_->bug_id, $_->last_visit_ts, $params)
+ } @last_visits
+ ];
}
sub _bug_user_last_visit_to_hash {
- my ($self, $bug_id, $last_visit_ts, $params) = @_;
+ my ($self, $bug_id, $last_visit_ts, $params) = @_;
- my %result = (id => $self->type('int', $bug_id),
- last_visit_ts => $self->type('dateTime', $last_visit_ts));
+ my %result = (
+ id => $self->type('int', $bug_id),
+ last_visit_ts => $self->type('dateTime', $last_visit_ts)
+ );
- return filter($params, \%result);
+ return filter($params, \%result);
}
1;