Merge "Improve suggest user performance when adding a reviewer."
This commit is contained in:
@@ -224,16 +224,27 @@ class SuggestServiceImpl extends BaseServiceImplementation implements
|
|||||||
} catch (NoSuchChangeException e) {
|
} catch (NoSuchChangeException e) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
VisibilityControl visibilityControl = new VisibilityControl() {
|
|
||||||
@Override
|
VisibilityControl visibilityControl;
|
||||||
public boolean isVisible(Account account) throws OrmException {
|
if (changeControl.getRefControl().isVisibleByRegisteredUsers()) {
|
||||||
IdentifiedUser who =
|
visibilityControl = new VisibilityControl() {
|
||||||
identifiedUserFactory.create(reviewDbProvider, account.getId());
|
@Override
|
||||||
// we can't use changeControl directly as it won't suggest reviewers
|
public boolean isVisible(Account account) throws OrmException {
|
||||||
// to drafts
|
return true;
|
||||||
return changeControl.forUser(who).isRefVisible();
|
}
|
||||||
}
|
};
|
||||||
};
|
} else {
|
||||||
|
visibilityControl = new VisibilityControl() {
|
||||||
|
@Override
|
||||||
|
public boolean isVisible(Account account) throws OrmException {
|
||||||
|
IdentifiedUser who =
|
||||||
|
identifiedUserFactory.create(reviewDbProvider, account.getId());
|
||||||
|
// we can't use changeControl directly as it won't suggest reviewers
|
||||||
|
// to drafts
|
||||||
|
return changeControl.forUser(who).isRefVisible();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
final List<AccountInfo> suggestedAccounts =
|
final List<AccountInfo> suggestedAccounts =
|
||||||
suggestAccount(db, query, Boolean.TRUE, limit, visibilityControl);
|
suggestAccount(db, query, Boolean.TRUE, limit, visibilityControl);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import com.google.gerrit.common.data.PermissionRange;
|
|||||||
import com.google.gerrit.common.data.PermissionRule;
|
import com.google.gerrit.common.data.PermissionRule;
|
||||||
import com.google.gerrit.common.data.RefConfigSection;
|
import com.google.gerrit.common.data.RefConfigSection;
|
||||||
import com.google.gerrit.common.errors.InvalidNameException;
|
import com.google.gerrit.common.errors.InvalidNameException;
|
||||||
|
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.server.CurrentUser;
|
import com.google.gerrit.server.CurrentUser;
|
||||||
import com.google.gerrit.server.IdentifiedUser;
|
import com.google.gerrit.server.IdentifiedUser;
|
||||||
@@ -106,6 +107,25 @@ public class RefControl {
|
|||||||
&& canRead();
|
&& canRead();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True if this reference is visible by all REGISTERED_USERS
|
||||||
|
*/
|
||||||
|
public boolean isVisibleByRegisteredUsers() {
|
||||||
|
List<PermissionRule> access = relevant.getPermission(Permission.READ);
|
||||||
|
for (PermissionRule rule : access) {
|
||||||
|
if (rule.isBlock()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (PermissionRule rule : access) {
|
||||||
|
if (rule.getGroup().getUUID().equals(AccountGroup.ANONYMOUS_USERS)
|
||||||
|
|| rule.getGroup().getUUID().equals(AccountGroup.REGISTERED_USERS)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether the user can upload a change to the ref controlled by
|
* Determines whether the user can upload a change to the ref controlled by
|
||||||
* this object.
|
* this object.
|
||||||
|
|||||||
Reference in New Issue
Block a user