Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 24 additions & 13 deletions gdettt/src/main/java/org/compass/gdet/GitHubAPIDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<GHUser, Integer> 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<GHUser, Integer> 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<GHUser, Integer> prMergedPerUser =
Expand All @@ -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<GHUser, Integer> 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");
Expand Down Expand Up @@ -120,7 +131,7 @@ public static void main( String[] args ) {
for(GHBranch gb : gbs)
{
System.out.print(GithubDataExtractionTool.branchToString(gb));
}
}

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,54 @@ public static Map<GHUser, Integer> getIssueCountPerUser(List<GHIssue> issues) {
return new WeakHashMap<GHUser, Integer>();
}
}
/** 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<GHUser, Integer> - a map of users to issue count
* Returns an empty map
* if an IOException is encountered.
*/
public static Map<GHUser, Integer> getPullRequestReviewCommentCountPerUser(GHRepository repo) {
List<GHPullRequestReviewComment> 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<GHUser, Integer> - a map of users to pull request review comments count
* Returns an empty map
* if an IOException is encountered.
*/
public static Map<GHUser, Integer> getPullRequestReviewCommentCountPerUser(List<GHPullRequestReviewComment> prrcs) {
try {
Map<GHUser, Integer> map = new WeakHashMap<GHUser, Integer>();
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<GHUser, Integer>();
}
}

/**getPullRequestOpenedCountPerUser
*
* This method will return a map of users and the count of pull requests
Expand Down