From fe326255202dcfac8b0991ca9d28e3cf4bcc4fe6 Mon Sep 17 00:00:00 2001 From: James Moger Date: Sun, 23 Oct 2011 12:28:48 -0400 Subject: [PATCH] Per-repository setting to skip summary metrics --- docs/00_index.mkd | 2 ++ docs/04_releases.mkd | 2 ++ src/com/gitblit/GitBlit.java | 2 ++ src/com/gitblit/client/EditRepositoryDialog.java | 7 +++++++ src/com/gitblit/client/RepositoriesTableModel.java | 5 ++++- src/com/gitblit/models/RepositoryModel.java | 1 + src/com/gitblit/wicket/GitBlitWebApp.properties | 4 +++- src/com/gitblit/wicket/pages/EditRepositoryPage.html | 9 +++++---- src/com/gitblit/wicket/pages/EditRepositoryPage.java | 1 + src/com/gitblit/wicket/pages/SummaryPage.java | 6 ++++-- 10 files changed, 31 insertions(+), 8 deletions(-) diff --git a/docs/00_index.mkd b/docs/00_index.mkd index f34fd559..86272690 100644 --- a/docs/00_index.mkd +++ b/docs/00_index.mkd @@ -38,6 +38,8 @@ Gitblit requires a Java 6 Runtime Environment (JRE) or a Java 6 Development Kit **New:** *web.enableRpcAdministration = false* - added: reusable JSON RPC client class - added: Gitblit Manager (Java/Swing Application) for remote administration of a Gitblit server. +- added: per-repository setting to skip size calculation (faster repositories page loading) +- added: per-repository setting to skip summary metrics calculation (faster summary page loading) - fixed: federation protocol timestamps. dates are now serialized to the [iso8601](http://en.wikipedia.org/wiki/ISO_8601) standard. **This breaks 0.6.0 federation clients/servers.** - fixed: collision on rename for repositories and users diff --git a/docs/04_releases.mkd b/docs/04_releases.mkd index 4b538ba9..e844322b 100644 --- a/docs/04_releases.mkd +++ b/docs/04_releases.mkd @@ -12,6 +12,8 @@ **New:** *web.enableRpcAdministration = false* - added: reusable JSON RPC client class - added: Gitblit Manager (Java/Swing Application) for remote administration of a Gitblit server. +- added: per-repository setting to skip size calculation (faster repositories page loading) +- added: per-repository setting to skip summary metrics calculation (faster summary page loading) - fixed: federation protocol timestamps. dates are now serialized to the [iso8601](http://en.wikipedia.org/wiki/ISO_8601) standard. **This breaks 0.6.0 federation clients/servers.** - fixed: collision on rename for repositories and users diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java index 49f93e4e..ffef94a7 100644 --- a/src/com/gitblit/GitBlit.java +++ b/src/com/gitblit/GitBlit.java @@ -594,6 +594,7 @@ public class GitBlit implements ServletContextListener { model.isFrozen = getConfig(config, "isFrozen", false); model.showReadme = getConfig(config, "showReadme", false); model.skipSizeCalculation = getConfig(config, "skipSizeCalculation", false); + model.skipSummaryMetrics = getConfig(config, "skipSummaryMetrics", false); model.federationStrategy = FederationStrategy.fromName(getConfig(config, "federationStrategy", null)); model.federationSets = new ArrayList(Arrays.asList(config.getStringList( @@ -814,6 +815,7 @@ public class GitBlit implements ServletContextListener { config.setBoolean("gitblit", null, "isFrozen", repository.isFrozen); config.setBoolean("gitblit", null, "showReadme", repository.showReadme); config.setBoolean("gitblit", null, "skipSizeCalculation", repository.skipSizeCalculation); + config.setBoolean("gitblit", null, "skipSummaryMetrics", repository.skipSummaryMetrics); config.setStringList("gitblit", null, "federationSets", repository.federationSets); config.setString("gitblit", null, "federationStrategy", repository.federationStrategy.name()); diff --git a/src/com/gitblit/client/EditRepositoryDialog.java b/src/com/gitblit/client/EditRepositoryDialog.java index c2d8f672..55f5268e 100644 --- a/src/com/gitblit/client/EditRepositoryDialog.java +++ b/src/com/gitblit/client/EditRepositoryDialog.java @@ -85,6 +85,8 @@ public class EditRepositoryDialog extends JDialog { private JCheckBox skipSizeCalculation; + private JCheckBox skipSummaryMetrics; + private JCheckBox isFrozen; private JComboBox accessRestriction; @@ -150,6 +152,8 @@ public class EditRepositoryDialog extends JDialog { anRepository.showReadme); skipSizeCalculation = new JCheckBox(Translation.get("gb.skipSizeCalculationDescription"), anRepository.skipSizeCalculation); + skipSummaryMetrics = new JCheckBox(Translation.get("gb.skipSummaryMetricsDescription"), + anRepository.skipSummaryMetrics); isFrozen = new JCheckBox(Translation.get("gb.isFrozenDescription"), anRepository.isFrozen); accessRestriction = new JComboBox(AccessRestrictionType.values()); @@ -180,6 +184,8 @@ public class EditRepositoryDialog extends JDialog { fieldsPanel.add(newFieldPanel(Translation.get("gb.showReadme"), showReadme)); fieldsPanel.add(newFieldPanel(Translation.get("gb.skipSizeCalculation"), skipSizeCalculation)); + fieldsPanel + .add(newFieldPanel(Translation.get("gb.skipSummaryMetrics"), skipSummaryMetrics)); fieldsPanel.add(newFieldPanel(Translation.get("gb.isFrozen"), isFrozen)); usersPalette = new JPalette(); @@ -327,6 +333,7 @@ public class EditRepositoryDialog extends JDialog { repository.showRemoteBranches = showRemoteBranches.isSelected(); repository.showReadme = showReadme.isSelected(); repository.skipSizeCalculation = skipSizeCalculation.isSelected(); + repository.skipSummaryMetrics = skipSummaryMetrics.isSelected(); repository.isFrozen = isFrozen.isSelected(); repository.accessRestriction = (AccessRestrictionType) accessRestriction.getSelectedItem(); diff --git a/src/com/gitblit/client/RepositoriesTableModel.java b/src/com/gitblit/client/RepositoriesTableModel.java index 9dd1a998..c3eaf6e5 100644 --- a/src/com/gitblit/client/RepositoriesTableModel.java +++ b/src/com/gitblit/client/RepositoriesTableModel.java @@ -117,7 +117,10 @@ public class RepositoriesTableModel extends AbstractTableModel { case Last_Change: return model.lastChange; case Size: - return model.size; + if (model.hasCommits) { + return model.size; + } + return "(empty)"; } return null; } diff --git a/src/com/gitblit/models/RepositoryModel.java b/src/com/gitblit/models/RepositoryModel.java index 6909f1a4..9a774fbd 100644 --- a/src/com/gitblit/models/RepositoryModel.java +++ b/src/com/gitblit/models/RepositoryModel.java @@ -51,6 +51,7 @@ public class RepositoryModel implements Serializable, Comparable federationSets; public boolean isFederated; public boolean skipSizeCalculation; + public boolean skipSummaryMetrics; public String frequency; public String origin; public String size; diff --git a/src/com/gitblit/wicket/GitBlitWebApp.properties b/src/com/gitblit/wicket/GitBlitWebApp.properties index 6d713e3f..ae6f6cfa 100644 --- a/src/com/gitblit/wicket/GitBlitWebApp.properties +++ b/src/com/gitblit/wicket/GitBlitWebApp.properties @@ -160,4 +160,6 @@ gb.settings = settings gb.manage = manage gb.lastLogin = last login gb.skipSizeCalculation = skip size calculation -gb.skipSizeCalculationDescription = do not calculate the repository size \ No newline at end of file +gb.skipSizeCalculationDescription = do not calculate the repository size (reduces page load time) +gb.skipSummaryMetrics = skip summary metrics +gb.skipSummaryMetricsDescription = do not calculate metrics on the summary page (reduces page load time) \ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/EditRepositoryPage.html b/src/com/gitblit/wicket/pages/EditRepositoryPage.html index cb216870..27a5448b 100644 --- a/src/com/gitblit/wicket/pages/EditRepositoryPage.html +++ b/src/com/gitblit/wicket/pages/EditRepositoryPage.html @@ -19,14 +19,15 @@       -   +   +  
-
- -   +   diff --git a/src/com/gitblit/wicket/pages/EditRepositoryPage.java b/src/com/gitblit/wicket/pages/EditRepositoryPage.java index ee79d500..be88bd5f 100644 --- a/src/com/gitblit/wicket/pages/EditRepositoryPage.java +++ b/src/com/gitblit/wicket/pages/EditRepositoryPage.java @@ -213,6 +213,7 @@ public class EditRepositoryPage extends RootSubPage { form.add(new CheckBox("showRemoteBranches")); form.add(new CheckBox("showReadme")); form.add(new CheckBox("skipSizeCalculation")); + form.add(new CheckBox("skipSummaryMetrics")); form.add(usersPalette); form.add(federationSetsPalette); diff --git a/src/com/gitblit/wicket/pages/SummaryPage.java b/src/com/gitblit/wicket/pages/SummaryPage.java index 50810a18..da573d5a 100644 --- a/src/com/gitblit/wicket/pages/SummaryPage.java +++ b/src/com/gitblit/wicket/pages/SummaryPage.java @@ -43,6 +43,7 @@ import com.gitblit.GitBlit; import com.gitblit.Keys; import com.gitblit.models.Metric; import com.gitblit.models.PathModel; +import com.gitblit.models.RepositoryModel; import com.gitblit.utils.JGitUtils; import com.gitblit.utils.MarkdownUtils; import com.gitblit.utils.StringUtils; @@ -64,10 +65,11 @@ public class SummaryPage extends RepositoryPage { int numberRefs = GitBlit.getInteger(Keys.web.summaryRefsCount, 5); Repository r = getRepository(); + RepositoryModel model = getRepositoryModel(); List metrics = null; Metric metricsTotal = null; - if (GitBlit.getBoolean(Keys.web.generateActivityGraph, true)) { - metrics = GitBlit.self().getRepositoryDefaultMetrics(getRepositoryModel(), r); + if (!model.skipSummaryMetrics && GitBlit.getBoolean(Keys.web.generateActivityGraph, true)) { + metrics = GitBlit.self().getRepositoryDefaultMetrics(model, r); metricsTotal = metrics.remove(0); } -- 2.39.5