From 0e44acbb2fec928a1606dc60f427a148fff405c9 Mon Sep 17 00:00:00 2001
From: Mohamed Ragab <moragab@gmail.com>
Date: Wed, 02 May 2012 11:15:01 -0400
Subject: [PATCH] Added a script to facilitate setting the proxy host and port and no proxy hosts, and then it concatenates all the java system properties for setting the java proxy configurations and puts the resulting string in an environment variable JAVA_PROXY_CONFIG, modified the scirpts gitblit, gitblit-ubuntu, and gitblit-centos to source the java-proxy-config.sh script and then include the resulting java proxy configuration in the java command
---
src/com/gitblit/wicket/pages/MetricsPage.java | 64 +++++++++++++++-----------------
1 files changed, 30 insertions(+), 34 deletions(-)
diff --git a/src/com/gitblit/wicket/pages/MetricsPage.java b/src/com/gitblit/wicket/pages/MetricsPage.java
index 2186ae3..f6df7c5 100644
--- a/src/com/gitblit/wicket/pages/MetricsPage.java
+++ b/src/com/gitblit/wicket/pages/MetricsPage.java
@@ -17,16 +17,16 @@
import java.awt.Color;
import java.awt.Dimension;
-import java.text.ParseException;
+import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
-import java.util.Date;
import java.util.List;
import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.basic.Label;
import org.eclipse.jgit.lib.Repository;
import org.wicketstuff.googlecharts.Chart;
import org.wicketstuff.googlecharts.ChartAxis;
@@ -40,6 +40,8 @@
import com.gitblit.models.Metric;
import com.gitblit.utils.MetricUtils;
+import com.gitblit.utils.StringUtils;
+import com.gitblit.utils.TimeUtils;
import com.gitblit.wicket.WicketUtils;
public class MetricsPage extends RepositoryPage {
@@ -47,10 +49,24 @@
public MetricsPage(PageParameters params) {
super(params);
Repository r = getRepository();
- insertLinePlot("commitsChart", MetricUtils.getDateMetrics(r, false));
- insertBarPlot("dayOfWeekChart", getDayOfWeekMetrics(r));
- insertLinePlot("timeOfDayChart", getTimeOfDayMetrics(r));
- insertPieChart("authorsChart", getAuthorMetrics(r));
+ if (StringUtils.isEmpty(objectId)) {
+ add(new Label("branchTitle", getRepositoryModel().HEAD));
+ } else {
+ add(new Label("branchTitle", objectId));
+ }
+ Metric metricsTotal = null;
+ List<Metric> metrics = MetricUtils.getDateMetrics(r, objectId, true, null, getTimeZone());
+ metricsTotal = metrics.remove(0);
+ if (metricsTotal == null) {
+ add(new Label("branchStats", ""));
+ } else {
+ add(new Label("branchStats",
+ MessageFormat.format(getString("gb.branchStats"), metricsTotal.count,
+ metricsTotal.tag, TimeUtils.duration(metricsTotal.duration))));
+ }
+ insertLinePlot("commitsChart", metrics);
+ insertBarPlot("dayOfWeekChart", getDayOfWeekMetrics(r, objectId));
+ insertPieChart("authorsChart", getAuthorMetrics(r, objectId));
}
private void insertLinePlot(String wicketId, List<Metric> metrics) {
@@ -110,7 +126,7 @@
for (Metric metric : metrics) {
labels.add(metric.name);
}
- ChartProvider provider = new ChartProvider(new Dimension(400, 200), ChartType.PIE, data);
+ ChartProvider provider = new ChartProvider(new Dimension(800, 200), ChartType.PIE, data);
provider.setPieLabels(labels.toArray(new String[labels.size()]));
add(new Chart(wicketId, provider));
} else {
@@ -118,12 +134,12 @@
}
}
- private List<Metric> getDayOfWeekMetrics(Repository repository) {
- List<Metric> list = MetricUtils.getDateMetrics(repository, false, "E");
+ private List<Metric> getDayOfWeekMetrics(Repository repository, String objectId) {
+ List<Metric> list = MetricUtils.getDateMetrics(repository, objectId, false, "E", getTimeZone());
SimpleDateFormat sdf = new SimpleDateFormat("E");
Calendar cal = Calendar.getInstance();
- List<Metric> sorted = new ArrayList<Metric>(7);
+ List<Metric> sorted = new ArrayList<Metric>();
int firstDayOfWeek = cal.getFirstDayOfWeek();
int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
@@ -133,7 +149,7 @@
String day = sdf.format(cal.getTime());
for (Metric metric : list) {
if (metric.name.equals(day)) {
- sorted.add(i, metric);
+ sorted.add(metric);
list.remove(metric);
break;
}
@@ -143,35 +159,15 @@
return sorted;
}
- private List<Metric> getTimeOfDayMetrics(Repository repository) {
- SimpleDateFormat ndf = new SimpleDateFormat("yyyy-MM-dd");
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
- List<Metric> list = MetricUtils.getDateMetrics(repository, false, "yyyy-MM-dd HH:mm");
- Calendar cal = Calendar.getInstance();
-
- for (Metric metric : list) {
- try {
- Date date = sdf.parse(metric.name);
- cal.setTime(date);
- double y = cal.get(Calendar.HOUR_OF_DAY) + (cal.get(Calendar.MINUTE) / 60d);
- metric.duration = (int) (date.getTime() / 60000L);
- metric.count = y;
- metric.name = ndf.format(date);
- } catch (ParseException p) {
- }
- }
- return list;
- }
-
- private List<Metric> getAuthorMetrics(Repository repository) {
- List<Metric> authors = MetricUtils.getAuthorMetrics(repository);
+ private List<Metric> getAuthorMetrics(Repository repository, String objectId) {
+ List<Metric> authors = MetricUtils.getAuthorMetrics(repository, objectId, true);
Collections.sort(authors, new Comparator<Metric>() {
@Override
public int compare(Metric o1, Metric o2) {
if (o1.count > o2.count) {
return -1;
} else if (o1.count < o2.count) {
- return 1;
+ return 1;
}
return 0;
}
--
Gitblit v1.9.1