diff options
author | Perl Tidy <perltidy@bugzilla.org> | 2018-12-05 21:38:52 +0100 |
---|---|---|
committer | Dylan William Hardison <dylan@hardison.net> | 2018-12-05 23:49:08 +0100 |
commit | 8ec8da0491ad89604700b3e29a227966f6d84ba1 (patch) | |
tree | 9d270f173330ca19700e0ba9f2ee931300646de1 /extensions/MyDashboard/lib/WebService.pm | |
parent | a7bb5a65b71644d9efce5fed783ed545b9336548 (diff) | |
download | bugzilla-8ec8da0491ad89604700b3e29a227966f6d84ba1.tar.gz bugzilla-8ec8da0491ad89604700b3e29a227966f6d84ba1.tar.xz |
no bug - reformat all the code using the new perltidy rules
Diffstat (limited to 'extensions/MyDashboard/lib/WebService.pm')
-rw-r--r-- | extensions/MyDashboard/lib/WebService.pm | 220 |
1 files changed, 110 insertions, 110 deletions
diff --git a/extensions/MyDashboard/lib/WebService.pm b/extensions/MyDashboard/lib/WebService.pm index 5407c1d0b..6638bacf2 100644 --- a/extensions/MyDashboard/lib/WebService.pm +++ b/extensions/MyDashboard/lib/WebService.pm @@ -17,149 +17,149 @@ use Bugzilla::Error; 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); +use Bugzilla::Extension::MyDashboard::Queries + qw(QUERY_DEFS query_bugs query_flags); use Bugzilla::Extension::MyDashboard::BugInterest; use constant READ_ONLY => qw( - run_bug_query - run_flag_query + run_bug_query + run_flag_query ); use constant PUBLIC_METHODS => qw( - bug_interest_unmark - run_bug_query - run_flag_query - run_last_changes + bug_interest_unmark + run_bug_query + run_flag_query + run_last_changes ); sub run_last_changes { - my ($self, $params) = @_; + my ($self, $params) = @_; - my $dbh = Bugzilla->dbh; - my $user = Bugzilla->login(LOGIN_REQUIRED); + my $dbh = Bugzilla->dbh; + my $user = Bugzilla->login(LOGIN_REQUIRED); - trick_taint($params->{changeddate_api}); - trick_taint($params->{bug_id}); + trick_taint($params->{changeddate_api}); + trick_taint($params->{bug_id}); - my $last_comment_sql = " + my $last_comment_sql = " SELECT comment_id FROM longdescs WHERE bug_id = ? AND bug_when > ?"; - if (!$user->is_insider) { - $last_comment_sql .= " AND isprivate = 0"; + if (!$user->is_insider) { + $last_comment_sql .= " AND isprivate = 0"; + } + $last_comment_sql .= " LIMIT 1"; + my $last_comment_sth = $dbh->prepare($last_comment_sql); + + my $last_changes = {}; + my $activity + = $self->history({ + ids => [$params->{bug_id}], new_since => $params->{changeddate_api} + }); + if (@{$activity->{bugs}[0]{history}}) { + my $change_set = $activity->{bugs}[0]{history}[0]; + $last_changes->{activity} = $change_set->{changes}; + foreach my $change (@{$last_changes->{activity}}) { + $change->{field_desc} = template_var('field_descs')->{$change->{field_name}} + || $change->{field_name}; } - $last_comment_sql .= " LIMIT 1"; - my $last_comment_sth = $dbh->prepare($last_comment_sql); - - my $last_changes = {}; - my $activity = $self->history({ ids => [ $params->{bug_id} ], - new_since => $params->{changeddate_api} }); - if (@{$activity->{bugs}[0]{history}}) { - my $change_set = $activity->{bugs}[0]{history}[0]; - $last_changes->{activity} = $change_set->{changes}; - foreach my $change (@{ $last_changes->{activity} }) { - $change->{field_desc} - = template_var('field_descs')->{$change->{field_name}} || $change->{field_name}; - } - $last_changes->{email} = $change_set->{who}; - my $datetime = datetime_from($change_set->{when}); - $datetime->set_time_zone($user->timezone); - $last_changes->{when} = $datetime->strftime('%Y-%m-%d %T %Z'); - } - my $last_comment_id = $dbh->selectrow_array( - $last_comment_sth, undef, $params->{bug_id}, $params->{changeddate_api}); - if ($last_comment_id) { - my $comments = $self->comments({ comment_ids => [ $last_comment_id ] }); - my $comment = $comments->{comments}{$last_comment_id}; - $last_changes->{comment} = $comment->{text}; - $last_changes->{email} = $comment->{creator} if !$last_changes->{email}; - my $datetime = datetime_from($comment->{creation_time}); - $datetime->set_time_zone($user->timezone); - $last_changes->{when} = $datetime->strftime('%Y-%m-%d %T %Z'); - } - - return { results => [ {last_changes => $last_changes } ] }; + $last_changes->{email} = $change_set->{who}; + my $datetime = datetime_from($change_set->{when}); + $datetime->set_time_zone($user->timezone); + $last_changes->{when} = $datetime->strftime('%Y-%m-%d %T %Z'); + } + my $last_comment_id + = $dbh->selectrow_array($last_comment_sth, undef, $params->{bug_id}, + $params->{changeddate_api}); + if ($last_comment_id) { + my $comments = $self->comments({comment_ids => [$last_comment_id]}); + my $comment = $comments->{comments}{$last_comment_id}; + $last_changes->{comment} = $comment->{text}; + $last_changes->{email} = $comment->{creator} if !$last_changes->{email}; + my $datetime = datetime_from($comment->{creation_time}); + $datetime->set_time_zone($user->timezone); + $last_changes->{when} = $datetime->strftime('%Y-%m-%d %T %Z'); + } + + return {results => [{last_changes => $last_changes}]}; } sub run_bug_query { - my($self, $params) = @_; - my $dbh = Bugzilla->dbh; - my $user = Bugzilla->login(LOGIN_REQUIRED); - - defined $params->{query} - || ThrowCodeError('param_required', - { function => 'MyDashboard.run_bug_query', - param => 'query' }); - - my $result; - foreach my $qdef (QUERY_DEFS) { - next if $qdef->{name} ne $params->{query}; - my ($bugs, $query_string) = query_bugs($qdef); - - # Add last changes to each bug - foreach my $b (@$bugs) { - # Set the data type properly for webservice clients - # for non-string values. - $b->{bug_id} = $self->type('int', $b->{bug_id}); - } - - $query_string =~ s/^POSTDATA=&//; - $qdef->{bugs} = $bugs; - $qdef->{buffer} = $query_string; - $result = $qdef; - last; + my ($self, $params) = @_; + my $dbh = Bugzilla->dbh; + my $user = Bugzilla->login(LOGIN_REQUIRED); + + defined $params->{query} + || ThrowCodeError('param_required', + {function => 'MyDashboard.run_bug_query', param => 'query'}); + + my $result; + foreach my $qdef (QUERY_DEFS) { + next if $qdef->{name} ne $params->{query}; + my ($bugs, $query_string) = query_bugs($qdef); + + # Add last changes to each bug + foreach my $b (@$bugs) { + + # Set the data type properly for webservice clients + # for non-string values. + $b->{bug_id} = $self->type('int', $b->{bug_id}); } - return { result => $result }; + $query_string =~ s/^POSTDATA=&//; + $qdef->{bugs} = $bugs; + $qdef->{buffer} = $query_string; + $result = $qdef; + last; + } + + return {result => $result}; } sub run_flag_query { - my ($self, $params) =@_; - my $user = Bugzilla->login(LOGIN_REQUIRED); - - my $type = $params->{type}; - $type || ThrowCodeError('param_required', - { function => 'MyDashboard.run_flag_query', - param => 'type' }); - - my $results = query_flags($type); - - # Set the data type properly for webservice clients - # for non-string values. - foreach my $flag (@$results) { - $flag->{id} = $self->type('int', $flag->{id}); - $flag->{attach_id} = $self->type('int', $flag->{attach_id}); - $flag->{bug_id} = $self->type('int', $flag->{bug_id}); - $flag->{is_patch} = $self->type('boolean', $flag->{is_patch}); - } - - return { result => { $type => $results }}; + my ($self, $params) = @_; + my $user = Bugzilla->login(LOGIN_REQUIRED); + + my $type = $params->{type}; + $type + || ThrowCodeError('param_required', + {function => 'MyDashboard.run_flag_query', param => 'type'}); + + my $results = query_flags($type); + + # Set the data type properly for webservice clients + # for non-string values. + foreach my $flag (@$results) { + $flag->{id} = $self->type('int', $flag->{id}); + $flag->{attach_id} = $self->type('int', $flag->{attach_id}); + $flag->{bug_id} = $self->type('int', $flag->{bug_id}); + $flag->{is_patch} = $self->type('boolean', $flag->{is_patch}); + } + + return {result => {$type => $results}}; } sub bug_interest_unmark { - my ($self, $params) = @_; - my $user = Bugzilla->login(LOGIN_REQUIRED); + my ($self, $params) = @_; + my $user = Bugzilla->login(LOGIN_REQUIRED); - ThrowCodeError('param_required', { function => 'MyDashboard.bug_interest_unmark', param => 'bug_ids' }) - unless $params->{bug_ids}; + ThrowCodeError('param_required', + {function => 'MyDashboard.bug_interest_unmark', param => 'bug_ids'}) + unless $params->{bug_ids}; - my @bug_ids = ref($params->{bug_ids}) ? @{$params->{bug_ids}} : ( $params->{bug_ids} ); + my @bug_ids + = ref($params->{bug_ids}) ? @{$params->{bug_ids}} : ($params->{bug_ids}); - Bugzilla->dbh->bz_start_transaction(); - foreach my $bug_id (@bug_ids) { - Bugzilla::Extension::MyDashboard::BugInterest->unmark($user->id, $bug_id); - } - Bugzilla->dbh->bz_commit_transaction(); + Bugzilla->dbh->bz_start_transaction(); + foreach my $bug_id (@bug_ids) { + Bugzilla::Extension::MyDashboard::BugInterest->unmark($user->id, $bug_id); + } + Bugzilla->dbh->bz_commit_transaction(); } sub rest_resources { - return [ - qr{^/bug_interest_unmark$}, { - PUT => { - method => 'bug_interest_unmark' - } - } - ]; + return [qr{^/bug_interest_unmark$}, {PUT => {method => 'bug_interest_unmark'}}]; } 1; |