diff options
author | dklawren <dklawren@users.noreply.github.com> | 2018-07-27 16:17:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-27 16:17:50 +0200 |
commit | 694a37b9debdf280d279b39b44329adda5caff40 (patch) | |
tree | e9e6cb6cd7bfabf81ed1012a96c1ac8f2f546153 /extensions/PhabBugz | |
parent | acde857e4c2b250210a7dc7fe26ce6c382616c76 (diff) | |
download | bugzilla-694a37b9debdf280d279b39b44329adda5caff40.tar.gz bugzilla-694a37b9debdf280d279b39b44329adda5caff40.tar.xz |
Bug 1478540 - Update User.pm to load more than 100 users by using the paging functionality of Conduit API
Diffstat (limited to 'extensions/PhabBugz')
-rw-r--r-- | extensions/PhabBugz/lib/Feed.pm | 29 | ||||
-rw-r--r-- | extensions/PhabBugz/lib/User.pm | 16 |
2 files changed, 28 insertions, 17 deletions
diff --git a/extensions/PhabBugz/lib/Feed.pm b/extensions/PhabBugz/lib/Feed.pm index d238c6a43..7d6b4e0ed 100644 --- a/extensions/PhabBugz/lib/Feed.pm +++ b/extensions/PhabBugz/lib/Feed.pm @@ -322,20 +322,27 @@ sub group_query { # Make sure phab-bot also a member of the new project group so that it can # make policy changes to the private revisions - INFO("Setting project members for " . $project->name); - my $set_members = $self->get_group_members( $group ); - my @set_member_phids = uniq map { $_->phid } (@$set_members, $phab_user); + INFO( "Checking project members for " . $project->name ); + my $set_members = $self->get_group_members($group); + my @set_member_phids = uniq map { $_->phid } ( @$set_members, $phab_user ); my @current_member_phids = uniq map { $_->phid } @{ $project->members }; - my ($added, $removed) = diff_arrays(\@set_member_phids, \@current_member_phids); + my ( $removed, $added ) = diff_arrays( \@current_member_phids, \@set_member_phids ); - INFO('Adding members: ' . join( ',', @$added )); - $project->add_member( $_ ) foreach @$added; - INFO('Removing members: ' . join( ',', @$removed )); - $project->remove_member( $_ ) foreach @$removed; + if (@$added) { + INFO( 'Adding project members: ' . join( ',', @$added ) ); + $project->add_member($_) foreach @$added; + } + + if (@$removed) { + INFO( 'Removing project members: ' . join( ',', @$removed ) ); + $project->remove_member($_) foreach @$removed; + } - my $result = $project->update(); - local Bugzilla::Logging->fields->{api_result} = $result; - INFO("Project " . $project->name . " updated"); + if (@$added || @$removed) { + my $result = $project->update(); + local Bugzilla::Logging->fields->{api_result} = $result; + INFO( "Project " . $project->name . " updated" ); + } } } diff --git a/extensions/PhabBugz/lib/User.pm b/extensions/PhabBugz/lib/User.pm index 9d4e9eef4..1bf1a842d 100644 --- a/extensions/PhabBugz/lib/User.pm +++ b/extensions/PhabBugz/lib/User.pm @@ -131,14 +131,18 @@ sub match { attachments => { 'external-accounts' => 1 } }; + # We can only fetch 100 users at a time so we need to do this in lumps my $phab_users = []; - my $result = request( 'user.search', $data ); - - if ( exists $result->{result}{data} && @{ $result->{result}{data} } ) { - foreach my $user ( @{ $result->{result}{data} } ) { - push @$phab_users, $class->new($user); + my $result; + do { + $result = request( 'user.search', $data ); + if ( exists $result->{result}{data} && @{ $result->{result}{data} } ) { + foreach my $user ( @{ $result->{result}{data} } ) { + push @$phab_users, $class->new($user); + } } - } + $data->{after} = $result->{cursor}->{after}; + } while ($result->{cursor}->{after}); return $phab_users; } |