summaryrefslogtreecommitdiffstats
path: root/extensions/PhabBugz
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/PhabBugz')
-rw-r--r--extensions/PhabBugz/lib/Util.pm45
-rw-r--r--extensions/PhabBugz/lib/WebService.pm105
2 files changed, 2 insertions, 148 deletions
diff --git a/extensions/PhabBugz/lib/Util.pm b/extensions/PhabBugz/lib/Util.pm
index a7ae98744..f2876366f 100644
--- a/extensions/PhabBugz/lib/Util.pm
+++ b/extensions/PhabBugz/lib/Util.pm
@@ -35,7 +35,6 @@ our @EXPORT = qw(
create_revision_attachment
get_attachment_revisions
get_bug_role_phids
- get_needs_review
intersect
is_attachment_phab_revision
request
@@ -206,48 +205,4 @@ sub set_phab_user {
return Bugzilla->set_user($user, scope_guard => 1);
}
-sub get_needs_review {
- my ($user) = @_;
- $user //= Bugzilla->user;
- return unless $user->id;
-
- my $phab_user = Bugzilla::Extension::PhabBugz::User->new_from_query(
- {
- ids => [ $user->id ]
- }
- );
-
- return [] unless $phab_user;
-
- my $diffs = request(
- 'differential.revision.search',
- {
- attachments => {
- reviewers => 1,
- },
- constraints => {
- reviewerPHIDs => [$phab_user->phid],
- statuses => ["open()"],
- },
- order => 'newest',
- }
- );
- ThrowCodeError('phabricator_api_error', { reason => 'Malformed Response' })
- unless exists $diffs->{result}{data};
-
- my @revisions;
- foreach my $revision ( @{ $diffs->{result}{data} } ) {
- foreach my $reviewer ( @{ $revision->{attachments}->{reviewers}->{reviewers} } ) {
- if ( $reviewer->{reviewerPHID} eq $phab_user->phid
- && $reviewer->{status} =~ /^(?:added|blocking)$/ )
- {
- push @revisions, $revision;
- last;
- }
- }
- }
-
- return \@revisions;
-}
-
1;
diff --git a/extensions/PhabBugz/lib/WebService.pm b/extensions/PhabBugz/lib/WebService.pm
index fa9306667..19a758a70 100644
--- a/extensions/PhabBugz/lib/WebService.pm
+++ b/extensions/PhabBugz/lib/WebService.pm
@@ -16,29 +16,23 @@ use base qw(Bugzilla::WebService);
use Bugzilla::Constants;
use Bugzilla::Error;
use Bugzilla::User;
-use Bugzilla::Util qw(detaint_natural datetime_from time_ago trick_taint);
+use Bugzilla::Util qw(detaint_natural trick_taint);
use Bugzilla::WebService::Constants;
use Bugzilla::Extension::PhabBugz::Constants;
-use Bugzilla::Extension::PhabBugz::Util qw(
- get_needs_review
-);
-use DateTime ();
-use List::Util qw(first uniq);
+use List::Util qw(first);
use List::MoreUtils qw(any);
use MIME::Base64 qw(decode_base64);
use constant READ_ONLY => qw(
check_user_enter_bug_permission
check_user_permission_for_bug
- needs_review
);
use constant PUBLIC_METHODS => qw(
check_user_enter_bug_permission
check_user_permission_for_bug
- needs_review
set_build_target
);
@@ -99,95 +93,6 @@ sub check_user_enter_bug_permission {
};
}
-sub needs_review {
- my ($self, $params) = @_;
-
- $self->_check_phabricator();
-
- my $user = Bugzilla->login(LOGIN_REQUIRED);
- my $dbh = Bugzilla->dbh;
-
- my $reviews = get_needs_review();
-
- my $authors = Bugzilla::Extension::PhabBugz::User->match({
- phids => [
- uniq
- grep { defined }
- map { $_->{fields}{authorPHID} }
- @$reviews
- ]
- });
-
- my %author_phab_to_id = map { $_->phid => $_->bugzilla_user->id } @$authors;
- my %author_id_to_user = map { $_->bugzilla_user->id => $_->bugzilla_user } @$authors;
-
- # bug data
- my $visible_bugs = $user->visible_bugs([
- uniq
- grep { $_ }
- map { $_->{fields}{'bugzilla.bug-id'} }
- @$reviews
- ]);
-
- # get all bug statuses and summaries in a single query to avoid creation of
- # many bug objects
- my %bugs;
- if (@$visible_bugs) {
- #<<<
- my $bug_rows =$dbh->selectall_arrayref(
- 'SELECT bug_id, bug_status, short_desc ' .
- ' FROM bugs ' .
- ' WHERE bug_id IN (' . join(',', ('?') x @$visible_bugs) . ')',
- { Slice => {} },
- @$visible_bugs
- );
- #>>>
- %bugs = map { $_->{bug_id} => $_ } @$bug_rows;
- }
-
- # build result
- my $datetime_now = DateTime->now(time_zone => $user->timezone);
- my @result;
- foreach my $review (@$reviews) {
- my $review_flat = {
- id => $review->{id},
- title => $review->{fields}{title},
- url => Bugzilla->params->{phabricator_base_uri} . 'D' . $review->{id},
- };
-
- # show date in user's timezone
- my $datetime = DateTime->from_epoch(
- epoch => $review->{fields}{dateModified},
- time_zone => 'UTC'
- );
- $datetime->set_time_zone($user->timezone);
- $review_flat->{updated} = $datetime->strftime('%Y-%m-%d %T %Z');
- $review_flat->{updated_fancy} = time_ago($datetime, $datetime_now);
-
- # review requester
- if (my $author = $author_id_to_user{$author_phab_to_id{ $review->{fields}{authorPHID} }}) {
- $review_flat->{author_name} = $author->name;
- $review_flat->{author_email} = $author->email;
- }
- else {
- $review_flat->{author_name} = 'anonymous';
- $review_flat->{author_email} = 'anonymous';
- }
-
- # referenced bug
- if (my $bug_id = $review->{fields}{'bugzilla.bug-id'}) {
- my $bug = $bugs{$bug_id};
- $review_flat->{bug_id} = $bug_id;
- $review_flat->{bug_status} = $bug->{bug_status};
- $review_flat->{bug_summary} = $bug->{short_desc};
- }
-
- push @result, $review_flat;
- }
-
- return { result => \@result };
-}
-
sub set_build_target {
my ( $self, $params ) = @_;
@@ -257,12 +162,6 @@ sub rest_resources {
},
},
},
- # Review requests
- qw{^/phabbugz/needs_review$}, {
- GET => {
- method => 'needs_review',
- },
- }
];
}