]> source.dussan.org Git - gitblit.git/commitdiff
Fix skip summary metrics regression since introducing flotr2
authorTing <kxyfyh@vip.qq.com>
Wed, 16 Apr 2014 04:06:56 +0000 (00:06 -0400)
committerJames Moger <james.moger@gitblit.com>
Wed, 16 Apr 2014 04:06:56 +0000 (00:06 -0400)
src/main/java/com/gitblit/wicket/pages/SummaryPage.java

index eb6eb07ae3cb29b094d9ab72b1d41effa0d2c496..090c09526884f0bc07f3bfa9d15ff9d9240c4368 100644 (file)
 package com.gitblit.wicket.pages;\r
 \r
 import java.text.MessageFormat;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
 import java.text.ParseException;\r
 import java.text.SimpleDateFormat;\r
+import java.util.ArrayList;\r
 import java.util.Date;\r
+import java.util.List;\r
 \r
 import org.apache.wicket.Component;\r
 import org.apache.wicket.PageParameters;\r
@@ -156,21 +155,24 @@ public class SummaryPage extends RepositoryPage {
                        // global, no readme on summary page\r
                        add(new Label("readme").setVisible(false));\r
                }\r
-               \r
-               Charts charts = createCharts(metrics);\r
-               add(new HeaderContributor(charts));\r
-               \r
+\r
+               if (metrics == null || metrics.isEmpty()) {\r
+                       add(new Label("commitsChart").setVisible(false));\r
+               } else {\r
+                       Charts charts = createCharts(metrics);\r
+                       add(new HeaderContributor(charts));\r
+               }\r
        }\r
 \r
        @Override\r
        protected String getPageName() {\r
                return getString("gb.summary");\r
        }\r
-       \r
+\r
        private Charts createCharts(List<Metric> metrics) {\r
-               \r
+\r
                Charts charts = new Flotr2Charts();\r
-               \r
+\r
                SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");\r
                String displayFormat = "MMM dd";\r
                if(metrics.size() > 0 && metrics.get(0).name.length() == 7){\r
@@ -178,11 +180,11 @@ public class SummaryPage extends RepositoryPage {
                        displayFormat = "yyyy MMM";\r
                }\r
                df.setTimeZone(getTimeZone());\r
-                                       \r
+\r
                // build google charts\r
                Chart chart = charts.createLineChart("commitsChart", getString("gb.activity"), "day", getString("gb.commits"));\r
                chart.setDateFormat(displayFormat);\r
-       \r
+\r
                for (Metric metric : metrics) {\r
                        Date date;\r
                        try {\r