James Moger
2013-06-12 ada1a326fa36ceb46922006f87d4cff0c49e071f
src/main/java/com/gitblit/wicket/pages/DashboardPage.java
@@ -34,6 +34,7 @@
import java.util.Map;
import java.util.Set;
import java.util.TimeZone;
import java.util.TreeSet;
import org.apache.wicket.Component;
import org.apache.wicket.PageParameters;
@@ -94,7 +95,10 @@
         String message = readMarkdown(messageSource, "login.mkd");
         Component repositoriesMessage = new Label("repositoriesMessage", message);
         add(repositoriesMessage.setEscapeModelStrings(false));
         add(new Label("repositoriesPanel"));
         add(new Label("digests"));
         add(new Label("active").setVisible(false));
         add(new Label("starred").setVisible(false));
         add(new Label("owned").setVisible(false));
         return;
      }
@@ -120,7 +124,7 @@
      // parameters
      int daysBack = params == null ? 0 : WicketUtils.getDaysBack(params);
      if (daysBack < 1) {
         daysBack = 14;
         daysBack = 7;
      }
      Calendar c = Calendar.getInstance();
      c.add(Calendar.DATE, -1*daysBack);
@@ -132,7 +136,7 @@
      List<RepositoryModel> owned = new ArrayList<RepositoryModel>();
      List<RepositoryModel> active = new ArrayList<RepositoryModel>();
      for (RepositoryModel model : GitBlit.self().getRepositoryModels(user)) {
      for (RepositoryModel model : getRepositoryModels()) {
         if (model.isUsersPersonalRepository(user.username) || model.isOwner(user.username)) {
            owned.add(model);
         }
@@ -184,7 +188,20 @@
      
      // add the nifty charts
      if (!ArrayUtils.isEmpty(pushes)) {
         GoogleCharts charts = createCharts(pushes);
         // aggregate author exclusions
         Set<String> authorExclusions = new TreeSet<String>();
         for (String author : GitBlit.getStrings(Keys.web.metricAuthorExclusions)) {
            authorExclusions.add(author.toLowerCase());
         }
         for (RepositoryModel model : feedSources) {
            if (!ArrayUtils.isEmpty(model.metricAuthorExclusions)) {
               for (String author : model.metricAuthorExclusions) {
                  authorExclusions.add(author.toLowerCase());
               }
            }
         }
         GoogleCharts charts = createCharts(pushes, authorExclusions);
         add(new HeaderContributor(charts));
      }
      
@@ -356,7 +373,7 @@
    * @param recentPushes
    * @return
    */
   private GoogleCharts createCharts(List<PushLogEntry> recentPushes) {
   private GoogleCharts createCharts(List<PushLogEntry> recentPushes, Set<String> authorExclusions) {
      // activity metrics
      Map<String, Metric> repositoryMetrics = new HashMap<String, Metric>();
      Map<String, Metric> authorMetrics = new HashMap<String, Metric>();
@@ -372,11 +389,15 @@
         repositoryMetrics.get(repository).count += 1;
         
         for (RepositoryCommit commit : push.getCommits()) {
            String author = commit.getAuthorIdent().getName();
            if (!authorMetrics.containsKey(author)) {
               authorMetrics.put(author, new Metric(author));
            String author = StringUtils.removeNewlines(commit.getAuthorIdent().getName());
            String authorName = author.toLowerCase();
            String authorEmail = StringUtils.removeNewlines(commit.getAuthorIdent().getEmailAddress()).toLowerCase();
            if (!authorExclusions.contains(authorName) && !authorExclusions.contains(authorEmail)) {
               if (!authorMetrics.containsKey(author)) {
                  authorMetrics.put(author, new Metric(author));
               }
               authorMetrics.get(author).count += 1;
            }
            authorMetrics.get(author).count += 1;
         }
      }