diff --git a/gdettt/src/main/java/org/compass/gdet/GitHubAPIDemo.java b/gdettt/src/main/java/org/compass/gdet/GitHubAPIDemo.java index b9af41b..82fc75d 100644 --- a/gdettt/src/main/java/org/compass/gdet/GitHubAPIDemo.java +++ b/gdettt/src/main/java/org/compass/gdet/GitHubAPIDemo.java @@ -49,22 +49,22 @@ public static void main( String[] args ) { System.out.printf("User: %-20s Commit Count: %d\n", GithubDataExtractionTool.getGHUserNameWithFallback(user), commitsPerUser.get(user)); - } - - //Print Commit Count Per User - System.out.print(startSection); - System.out.println("PULL-REQUEST-OPENED-COUNT-PER-USER"); - System.out.print(endSection); - Map prPerUser = - GithubDataExtractionTool.getPullRequestCountPerUser(repo, false); - for (GHUser user : prPerUser.keySet()) { - System.out.printf("User: %-20s PR Opened Count: %d\n", - GithubDataExtractionTool.getGHUserNameWithFallback(user), - prPerUser.get(user)); } //Print Commit Count Per User System.out.print(startSection); + System.out.println("PULL-REQUEST-OPENED-COUNT-PER-USER"); + System.out.print(endSection); + Map prPerUser = + GithubDataExtractionTool.getPullRequestCountPerUser(repo, false); + for (GHUser user : prPerUser.keySet()) { + System.out.printf("User: %-20s PR Opened Count: %d\n", + GithubDataExtractionTool.getGHUserNameWithFallback(user), + prPerUser.get(user)); + } + + //Print Pull Request Count Per User + System.out.print(startSection); System.out.println("PULL-REQUEST-MERGED-COUNT-PER-USER"); System.out.print(endSection); Map prMergedPerUser = @@ -74,6 +74,17 @@ public static void main( String[] args ) { GithubDataExtractionTool.getGHUserNameWithFallback(user), prMergedPerUser.get(user)); } + //Print Pull Request Review CommentCount Per User + System.out.print(startSection); + System.out.println("PULL-REQUEST-REVIEW-COMMENT-COUNT-PER-USER"); + System.out.print(endSection); + Map prrcMergedPerUser = + GithubDataExtractionTool.getPullRequestReviewCommentCountPerUser(repo); + for (GHUser user : prrcMergedPerUser.keySet()) { + System.out.printf("User: %-20s Count: %d\n", + GithubDataExtractionTool.getGHUserNameWithFallback(user), + prrcMergedPerUser.get(user)); + } System.out.print(startSection); System.out.println("ISSUE-CREATED-COUNT-PER-USER"); @@ -120,7 +131,7 @@ public static void main( String[] args ) { for(GHBranch gb : gbs) { System.out.print(GithubDataExtractionTool.branchToString(gb)); - } + } } } diff --git a/gdettt/src/main/java/org/compass/gdet/GithubDataExtractionTool.java b/gdettt/src/main/java/org/compass/gdet/GithubDataExtractionTool.java index 7885e90..d46624d 100644 --- a/gdettt/src/main/java/org/compass/gdet/GithubDataExtractionTool.java +++ b/gdettt/src/main/java/org/compass/gdet/GithubDataExtractionTool.java @@ -290,7 +290,54 @@ public static Map getIssueCountPerUser(List issues) { return new WeakHashMap(); } } + /** getPullRequestReviewCommentCountPerUser + * Generates a mapping between all users who have pull request review comments with + * the repository and the number of pull request review comments made. + * + * @params: + * repo- a repository to find the issues counts per user from. + * + * @return: + * Map - a map of users to issue count + * Returns an empty map + * if an IOException is encountered. + */ + public static Map getPullRequestReviewCommentCountPerUser(GHRepository repo) { + List prrc = getPullRequestReviewComments(repo); + return getPullRequestReviewCommentCountPerUser(prrc); + } + /** getPullRequestReviewCommentCountPerUser + * Generates a mapping between all users who have made pr review comments with + * the repository and the number of pull request review comments they've made. + * + * @params: + * prrc- a list of pull request review comments. + * + * @return: + * Map - a map of users to pull request review comments count + * Returns an empty map + * if an IOException is encountered. + */ + public static Map getPullRequestReviewCommentCountPerUser(List prrcs) { + try { + Map map = new WeakHashMap(); + for (GHPullRequestReviewComment prrc: prrcs) { + GHUser prrcOpener = prrc.getUser(); + if (map.containsKey(prrcOpener)) { + map.put(prrcOpener, map.get(prrcOpener) + 1); + } + else { + map.put(prrcOpener, 1); + } + } + return map; + } + catch (IOException e) { + return new WeakHashMap(); + } + } + /**getPullRequestOpenedCountPerUser * * This method will return a map of users and the count of pull requests