diff options
Diffstat (limited to 'src/main/java/com/gitblit/wicket')
4 files changed, 77 insertions, 16 deletions
diff --git a/src/main/java/com/gitblit/wicket/charting/GooglePieChart.java b/src/main/java/com/gitblit/wicket/charting/GooglePieChart.java index 945e08b1..a9b46670 100644 --- a/src/main/java/com/gitblit/wicket/charting/GooglePieChart.java +++ b/src/main/java/com/gitblit/wicket/charting/GooglePieChart.java @@ -16,7 +16,9 @@ package com.gitblit.wicket.charting;
import java.text.MessageFormat;
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.List;
import com.gitblit.utils.StringUtils;
@@ -44,10 +46,27 @@ public class GooglePieChart extends GoogleChart { line(sb, MessageFormat.format("{0}.addRows({1,number,0});", dName, values.size()));
Collections.sort(values);
-
- StringBuilder colors = new StringBuilder("colors:[");
- for (int i = 0; i < values.size(); i++) {
+ List<ChartValue> list = new ArrayList<ChartValue>();
+
+ int maxSlices = 10;
+ int maxCount = Math.min(maxSlices - 1, values.size());
+
+ for (int i = 0; i < maxCount; i++) {
ChartValue value = values.get(i);
+ list.add(value);
+ }
+ if (values.size() >= maxSlices) {
+ float others = 0;
+ for (int i = maxSlices - 1; i < values.size(); i++) {
+ others += values.get(i).value;
+ }
+ ChartValue other = new ChartValue("other", others);
+ list.add(other);
+ }
+
+ StringBuilder colors = new StringBuilder("colors:[");
+ for (int i = 0; i < list.size(); i++) {
+ ChartValue value = list.get(i);
colors.append('\'');
colors.append(StringUtils.getColor(value.name));
colors.append('\'');
diff --git a/src/main/java/com/gitblit/wicket/pages/DashboardPage.java b/src/main/java/com/gitblit/wicket/pages/DashboardPage.java index 39771aef..66bbf734 100644 --- a/src/main/java/com/gitblit/wicket/pages/DashboardPage.java +++ b/src/main/java/com/gitblit/wicket/pages/DashboardPage.java @@ -34,6 +34,7 @@ import java.util.List; 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;
@@ -187,7 +188,20 @@ public class DashboardPage extends RootPage { // 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));
}
@@ -359,7 +373,7 @@ public class DashboardPage extends RootPage { * @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>();
@@ -375,11 +389,15 @@ public class DashboardPage extends RootPage { 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;
}
}
diff --git a/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.html b/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.html index f8ecb992..38070273 100644 --- a/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.html +++ b/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.html @@ -41,8 +41,9 @@ <tr><th><wicket:message key="gb.skipSizeCalculation"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="skipSizeCalculation" tabindex="11" /> <span class="help-inline"><wicket:message key="gb.skipSizeCalculationDescription"></wicket:message></span></label></td></tr>
<tr><th><wicket:message key="gb.skipSummaryMetrics"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="skipSummaryMetrics" tabindex="12" /> <span class="help-inline"><wicket:message key="gb.skipSummaryMetricsDescription"></wicket:message></span></label></td></tr>
<tr><th><wicket:message key="gb.maxActivityCommits"></wicket:message></th><td class="edit"><select class="span2" wicket:id="maxActivityCommits" tabindex="13" /> <span class="help-inline"><wicket:message key="gb.maxActivityCommitsDescription"></wicket:message></span></td></tr>
+ <tr><th><wicket:message key="gb.metricAuthorExclusions"></wicket:message></th><td class="edit"><input class="span8" type="text" wicket:id="metricAuthorExclusions" size="40" tabindex="14" /></td></tr>
<tr><th colspan="2"><hr/></th></tr>
- <tr><th><wicket:message key="gb.mailingLists"></wicket:message></th><td class="edit"><input class="span8" type="text" wicket:id="mailingLists" size="40" tabindex="14" /></td></tr>
+ <tr><th><wicket:message key="gb.mailingLists"></wicket:message></th><td class="edit"><input class="span8" type="text" wicket:id="mailingLists" size="40" tabindex="15" /></td></tr>
</tbody>
</table>
</div>
@@ -51,15 +52,15 @@ <div class="tab-pane" id="permissions">
<table class="plain">
<tbody class="settings">
- <tr><th><wicket:message key="gb.owners"></wicket:message></th><td class="edit"><span wicket:id="owners" tabindex="15" /> </td></tr>
+ <tr><th><wicket:message key="gb.owners"></wicket:message></th><td class="edit"><span wicket:id="owners" tabindex="16" /> </td></tr>
<tr><th colspan="2"><hr/></th></tr>
- <tr><th><wicket:message key="gb.accessRestriction"></wicket:message></th><td class="edit"><select class="span4" wicket:id="accessRestriction" tabindex="16" /></td></tr>
+ <tr><th><wicket:message key="gb.accessRestriction"></wicket:message></th><td class="edit"><select class="span4" wicket:id="accessRestriction" tabindex="17" /></td></tr>
<tr><th colspan="2"><hr/></th></tr>
<tr><th><wicket:message key="gb.authorizationControl"></wicket:message></th><td style="padding:2px;"><span class="authorizationControl" wicket:id="authorizationControl"></span></td></tr>
<tr><th colspan="2"><hr/></th></tr>
- <tr><th><wicket:message key="gb.isFrozen"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="isFrozen" tabindex="17" /> <span class="help-inline"><wicket:message key="gb.isFrozenDescription"></wicket:message></span></label></td></tr>
- <tr><th><wicket:message key="gb.allowForks"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="allowForks" tabindex="18" /> <span class="help-inline"><wicket:message key="gb.allowForksDescription"></wicket:message></span></label></td></tr>
- <tr><th><wicket:message key="gb.verifyCommitter"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="verifyCommitter" tabindex="19" /> <span class="help-inline"><wicket:message key="gb.verifyCommitterDescription"></wicket:message></span><br/><span class="help-inline" style="padding-left:10px;"><wicket:message key="gb.verifyCommitterNote"></wicket:message></span></label></td></tr>
+ <tr><th><wicket:message key="gb.isFrozen"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="isFrozen" tabindex="18" /> <span class="help-inline"><wicket:message key="gb.isFrozenDescription"></wicket:message></span></label></td></tr>
+ <tr><th><wicket:message key="gb.allowForks"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="allowForks" tabindex="19" /> <span class="help-inline"><wicket:message key="gb.allowForksDescription"></wicket:message></span></label></td></tr>
+ <tr><th><wicket:message key="gb.verifyCommitter"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="verifyCommitter" tabindex="20" /> <span class="help-inline"><wicket:message key="gb.verifyCommitterDescription"></wicket:message></span><br/><span class="help-inline" style="padding-left:10px;"><wicket:message key="gb.verifyCommitterNote"></wicket:message></span></label></td></tr>
<tr><th colspan="2"><hr/></th></tr>
<tr><th><wicket:message key="gb.userPermissions"></wicket:message></th><td style="padding:2px;"><span wicket:id="users"></span></td></tr>
<tr><th colspan="2"><hr/></th></tr>
@@ -72,7 +73,7 @@ <div class="tab-pane" id="federation">
<table class="plain">
<tbody class="settings">
- <tr><th><wicket:message key="gb.federationStrategy"></wicket:message></th><td class="edit"><select class="span4" wicket:id="federationStrategy" tabindex="20" /></td></tr>
+ <tr><th><wicket:message key="gb.federationStrategy"></wicket:message></th><td class="edit"><select class="span4" wicket:id="federationStrategy" tabindex="21" /></td></tr>
<tr><th><wicket:message key="gb.federationSets"></wicket:message></th><td style="padding:2px;"><span wicket:id="federationSets"></span></td></tr>
</tbody>
</table>
diff --git a/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java index 938b05e3..4c471a1e 100644 --- a/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java +++ b/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java @@ -76,6 +76,8 @@ public class EditRepositoryPage extends RootSubPage { RepositoryModel repositoryModel;
+ private IModel<String> metricAuthorExclusions;
+
private IModel<String> mailingLists;
public EditRepositoryPage() {
@@ -316,6 +318,23 @@ public class EditRepositoryPage extends RootSubPage { }
}
+ // set author metric exclusions
+ String ax = metricAuthorExclusions.getObject();
+ if (!StringUtils.isEmpty(ax)) {
+ Set<String> list = new HashSet<String>();
+ for (String exclusion : StringUtils.getStringsFromValue(ax, " ")) {
+ if (StringUtils.isEmpty(exclusion)) {
+ continue;
+ }
+ if (exclusion.indexOf(' ') > -1) {
+ list.add("\"" + exclusion + "\"");
+ } else {
+ list.add(exclusion);
+ }
+ }
+ repositoryModel.metricAuthorExclusions = new ArrayList<String>(list);
+ }
+
// set mailing lists
String ml = mailingLists.getObject();
if (!StringUtils.isEmpty(ml)) {
@@ -435,6 +454,10 @@ public class EditRepositoryPage extends RootSubPage { List<Integer> maxActivityCommits = Arrays.asList(-1, 0, 25, 50, 75, 100, 150, 200, 250, 500 );
form.add(new DropDownChoice<Integer>("maxActivityCommits", maxActivityCommits, new MaxActivityCommitsRenderer()));
+ metricAuthorExclusions = new Model<String>(ArrayUtils.isEmpty(repositoryModel.metricAuthorExclusions) ? ""
+ : StringUtils.flattenStrings(repositoryModel.metricAuthorExclusions, " "));
+ form.add(new TextField<String>("metricAuthorExclusions", metricAuthorExclusions));
+
mailingLists = new Model<String>(ArrayUtils.isEmpty(repositoryModel.mailingLists) ? ""
: StringUtils.flattenStrings(repositoryModel.mailingLists, " "));
form.add(new TextField<String>("mailingLists", mailingLists));
|