Search in sources :

Example 1 with GroupBaseInfo

use of com.google.gerrit.extensions.common.GroupBaseInfo in project gerrit by GerritCodeReview.

the class ReviewersUtil method suggestAccountGroups.

private List<SuggestedReviewerInfo> suggestAccountGroups(SuggestReviewers suggestReviewers, ProjectControl projectControl, VisibilityControl visibilityControl, int limit) throws OrmException, IOException {
    try (Timer0.Context ctx = metrics.queryGroupsLatency.start()) {
        List<SuggestedReviewerInfo> groups = new ArrayList<>();
        for (GroupReference g : suggestAccountGroups(suggestReviewers, projectControl)) {
            GroupAsReviewer result = suggestGroupAsReviewer(suggestReviewers, projectControl.getProject(), g, visibilityControl);
            if (result.allowed || result.allowedWithConfirmation) {
                GroupBaseInfo info = new GroupBaseInfo();
                info.id = Url.encode(g.getUUID().get());
                info.name = g.getName();
                SuggestedReviewerInfo suggestedReviewerInfo = new SuggestedReviewerInfo();
                suggestedReviewerInfo.group = info;
                suggestedReviewerInfo.count = result.size;
                if (result.allowedWithConfirmation) {
                    suggestedReviewerInfo.confirm = true;
                }
                groups.add(suggestedReviewerInfo);
                if (groups.size() >= limit) {
                    break;
                }
            }
        }
        return groups;
    }
}
Also used : SuggestedReviewerInfo(com.google.gerrit.extensions.common.SuggestedReviewerInfo) ArrayList(java.util.ArrayList) GroupBaseInfo(com.google.gerrit.extensions.common.GroupBaseInfo) Timer0(com.google.gerrit.metrics.Timer0) GroupReference(com.google.gerrit.common.data.GroupReference)

Example 2 with GroupBaseInfo

use of com.google.gerrit.extensions.common.GroupBaseInfo in project gerrit by GerritCodeReview.

the class ReviewersUtil method suggestAccountGroups.

private List<SuggestedReviewerInfo> suggestAccountGroups(SuggestReviewers suggestReviewers, ProjectState projectState, VisibilityControl visibilityControl, int limit) throws IOException {
    try (Timer0.Context ctx = metrics.queryGroupsLatency.start()) {
        List<SuggestedReviewerInfo> groups = new ArrayList<>();
        for (GroupReference g : suggestAccountGroups(suggestReviewers, projectState)) {
            GroupAsReviewer result = suggestGroupAsReviewer(suggestReviewers, projectState.getProject(), g, visibilityControl);
            if (result.allowed || result.allowedWithConfirmation) {
                GroupBaseInfo info = new GroupBaseInfo();
                info.id = Url.encode(g.getUUID().get());
                info.name = g.getName();
                SuggestedReviewerInfo suggestedReviewerInfo = new SuggestedReviewerInfo();
                suggestedReviewerInfo.group = info;
                suggestedReviewerInfo.count = result.size;
                if (result.allowedWithConfirmation) {
                    suggestedReviewerInfo.confirm = true;
                }
                groups.add(suggestedReviewerInfo);
                if (groups.size() >= limit) {
                    break;
                }
            }
        }
        return groups;
    }
}
Also used : SuggestedReviewerInfo(com.google.gerrit.extensions.common.SuggestedReviewerInfo) ArrayList(java.util.ArrayList) GroupBaseInfo(com.google.gerrit.extensions.common.GroupBaseInfo) Timer0(com.google.gerrit.metrics.Timer0) GroupReference(com.google.gerrit.entities.GroupReference)

Aggregations

GroupBaseInfo (com.google.gerrit.extensions.common.GroupBaseInfo)2 SuggestedReviewerInfo (com.google.gerrit.extensions.common.SuggestedReviewerInfo)2 Timer0 (com.google.gerrit.metrics.Timer0)2 ArrayList (java.util.ArrayList)2 GroupReference (com.google.gerrit.common.data.GroupReference)1 GroupReference (com.google.gerrit.entities.GroupReference)1