Skip to content
This repository has been archived by the owner on Jan 4, 2018. It is now read-only.

Commit

Permalink
Added another metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
kohsuke committed May 31, 2014
1 parent 4eb876d commit c3ea38e
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 2 deletions.
25 changes: 24 additions & 1 deletion src/main/java/org/jenkinsci/pullrequests/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@
import java.io.IOException;
import java.io.PrintStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.TimeUnit;

Expand Down Expand Up @@ -60,12 +63,32 @@ public int compare(GHPullRequest lhs, GHPullRequest rhs) {
return r;
}

private static List<Repository> groupByRepositories(List<GHPullRequest> prs) {
Map<String,Repository> r = new HashMap<String, Repository>();
for (GHPullRequest pr : prs) {
String name = pr.getRepository().getName();
Repository v = r.get(name);
if (v==null)
r.put(name,v=new Repository(name));
v.count++;
}

List<Repository> list = new ArrayList<Repository>(r.values());
Collections.sort(list);
return list;
}

private static ByteArrayOutputStream toWikiPage(List<GHPullRequest> r) throws IOException {
ByteArrayOutputStream page = new ByteArrayOutputStream();
PrintStream out = new PrintStream(page,true);

IOUtils.copy(Main.class.getResourceAsStream("byRepo.txt"), page);
for (Repository repo : groupByRepositories(r)) {
out.printf("|%30s|%4s|\n", repo.name, repo.count);
}

final Date now = new Date();
IOUtils.copy(Main.class.getResourceAsStream("preamble.txt"), page);
IOUtils.copy(Main.class.getResourceAsStream("unattended.txt"), page);
for (GHPullRequest p : r) {
final long daysSinceCreation = daysBetween(now, p.getCreatedAt());
final long daysSinceUpdate = daysBetween(now, p.getIssueUpdatedAt());
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/org/jenkinsci/pullrequests/Repository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.jenkinsci.pullrequests;

/**
* @author Kohsuke Kawaguchi
*/
public class Repository implements Comparable<Repository> {
final String name;
int count;

public Repository(String name) {
this.name = name;
}

/**
* We want descending sort, so comparing in the reverse order.
*/
public int compareTo(Repository that) {
return that.count - this.count;
}
}
4 changes: 4 additions & 0 deletions src/main/resources/org/jenkinsci/pullrequests/byRepo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
h1.Pending Pull Requests by Repository
This table lists the number of open pull requests by their count.

||Repository||Count||
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
This page lists open pull requests in the Jenkins GitHub repositories, sorted by the days of inactivity. To encourage contributions, we try to resolve pull requests within 2 weeks.



h1.Unattended pull requests
This table lists open pull requests in the Jenkins GitHub repositories, sorted by the days of inactivity. To encourage contributions, we try to resolve pull requests within 2 weeks.

If your pull requests aren't processed in a timely fashion, please drop us a note at the dev list, so that we can give you a push access. If the plugin is dormant, we'd love you to take over.

Expand Down

0 comments on commit c3ea38e

Please sign in to comment.