From f1720ca884bc3fa9da1288ad955e46f165aa4168 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Wed, 01 Jun 2011 08:09:46 -0400
Subject: [PATCH] Unit testing. Disable links on first commit. Initial stats page.

---
 src/com/gitblit/wicket/pages/SummaryPage.java |   50 +++-----------------------------------------------
 1 files changed, 3 insertions(+), 47 deletions(-)

diff --git a/src/com/gitblit/wicket/pages/SummaryPage.java b/src/com/gitblit/wicket/pages/SummaryPage.java
index 181de0d..1157d30 100644
--- a/src/com/gitblit/wicket/pages/SummaryPage.java
+++ b/src/com/gitblit/wicket/pages/SummaryPage.java
@@ -27,7 +27,6 @@
 import org.apache.wicket.markup.html.basic.Label;
 import org.apache.wicket.protocol.http.WebRequest;
 import org.eclipse.jgit.lib.Repository;
-import org.wicketstuff.googlecharts.AbstractChartData;
 import org.wicketstuff.googlecharts.Chart;
 import org.wicketstuff.googlecharts.ChartAxis;
 import org.wicketstuff.googlecharts.ChartAxisType;
@@ -73,7 +72,7 @@
 		List<Metric> metrics = null;
 		Metric metricsTotal = null;
 		if (GitBlit.getBoolean(Keys.web.generateActivityGraph, true)) {
-			metrics = JGitUtils.getDateMetrics(r);
+			metrics = JGitUtils.getDateMetrics(r, true);
 			metricsTotal = metrics.remove(0);
 		}
 
@@ -152,7 +151,7 @@
 	private void insertActivityGraph(List<Metric> metrics) {
 		if ((metrics != null) && (metrics.size() > 0)
 				&& GitBlit.getBoolean(Keys.web.generateActivityGraph, true)) {
-			IChartData data = getChartData(metrics);
+			IChartData data = WicketUtils.getChartData(metrics);
 
 			ChartProvider provider = new ChartProvider(new Dimension(400, 100), ChartType.LINE,
 					data);
@@ -162,7 +161,7 @@
 			provider.addAxis(dateAxis);
 
 			ChartAxis commitAxis = new ChartAxis(ChartAxisType.LEFT);
-			commitAxis.setLabels(new String[] { "", String.valueOf((int) maxValue(metrics)) });
+			commitAxis.setLabels(new String[] { "", String.valueOf((int) WicketUtils.maxValue(metrics)) });
 			provider.addAxis(commitAxis);
 
 			provider.setLineStyles(new LineStyle[] { new LineStyle(2, 4, 0), new LineStyle(0, 4, 1) });
@@ -172,48 +171,5 @@
 		} else {
 			add(WicketUtils.newBlankImage("commitsChart"));
 		}
-	}
-
-	protected IChartData getChartData(List<Metric> metrics) {
-		final double[] commits = new double[metrics.size()];
-		final double[] tags = new double[metrics.size()];
-		int i = 0;
-		double max = 0;
-		for (Metric m : metrics) {
-			commits[i] = m.count;
-			if (m.tag > 0) {
-				tags[i] = m.count;
-			} else {
-				tags[i] = -1d;
-			}
-			max = Math.max(max, m.count);
-			i++;
-		}
-		IChartData data = new AbstractChartData(max) {
-			private static final long serialVersionUID = 1L;
-
-			public double[][] getData() {
-				return new double[][] { commits, tags };
-			}
-		};
-		return data;
-	}
-
-	protected String[] getNames(List<Metric> results) {
-		String[] names = new String[results.size()];
-		for (int i = 0; i < results.size(); i++) {
-			names[i] = results.get(i).name;
-		}
-		return names;
-	}
-
-	protected double maxValue(List<Metric> metrics) {
-		double max = Double.MIN_VALUE;
-		for (Metric m : metrics) {
-			if (m.count > max) {
-				max = m.count;
-			}
-		}
-		return max;
 	}
 }

--
Gitblit v1.9.1