diff options
author | Ting <kxyfyh@vip.qq.com> | 2014-04-16 00:06:56 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-04-16 00:06:56 -0400 |
commit | d0751dc352ef06c067593f31f5423fce357f8f1f (patch) | |
tree | 93c279e0e14791745ebba760b95ac754a3a0857d /src | |
parent | a961100556e5a8aa301261f08319c54bc49ace59 (diff) | |
download | gitblit-d0751dc352ef06c067593f31f5423fce357f8f1f.tar.gz gitblit-d0751dc352ef06c067593f31f5423fce357f8f1f.zip |
Fix skip summary metrics regression since introducing flotr2
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/gitblit/wicket/pages/SummaryPage.java | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/main/java/com/gitblit/wicket/pages/SummaryPage.java b/src/main/java/com/gitblit/wicket/pages/SummaryPage.java index eb6eb07a..090c0952 100644 --- a/src/main/java/com/gitblit/wicket/pages/SummaryPage.java +++ b/src/main/java/com/gitblit/wicket/pages/SummaryPage.java @@ -16,12 +16,11 @@ package com.gitblit.wicket.pages;
import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.List;
-
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Date;
+import java.util.List;
import org.apache.wicket.Component;
import org.apache.wicket.PageParameters;
@@ -156,21 +155,24 @@ public class SummaryPage extends RepositoryPage { // global, no readme on summary page
add(new Label("readme").setVisible(false));
}
-
- Charts charts = createCharts(metrics);
- add(new HeaderContributor(charts));
-
+
+ if (metrics == null || metrics.isEmpty()) {
+ add(new Label("commitsChart").setVisible(false));
+ } else {
+ Charts charts = createCharts(metrics);
+ add(new HeaderContributor(charts));
+ }
}
@Override
protected String getPageName() {
return getString("gb.summary");
}
-
+
private Charts createCharts(List<Metric> metrics) {
-
+
Charts charts = new Flotr2Charts();
-
+
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String displayFormat = "MMM dd";
if(metrics.size() > 0 && metrics.get(0).name.length() == 7){
@@ -178,11 +180,11 @@ public class SummaryPage extends RepositoryPage { displayFormat = "yyyy MMM";
}
df.setTimeZone(getTimeZone());
-
+
// build google charts
Chart chart = charts.createLineChart("commitsChart", getString("gb.activity"), "day", getString("gb.commits"));
chart.setDateFormat(displayFormat);
-
+
for (Metric metric : metrics) {
Date date;
try {
|