Skip to content

Commit

Permalink
use settingsWrapper for fewer db queries #5253
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed Jul 22, 2019
1 parent 203bc7f commit 0b4d21f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
19 changes: 19 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,5 +241,24 @@ private void initLocaleSettings() {
// do we want to know? - probably not
}
}

public boolean isMakeDataCountEnabled(){
String logPath = systemConfig.getMDCLogPath();
if (logPath != null) {
return true;
} else {
return false;
}
}

public boolean isDoiInstallation() {
String protocol = getValueForKey(SettingsServiceBean.Key.Protocol);
if ("doi".equals(protocol)) {
return true;
} else {
return false;
}
}

}

10 changes: 5 additions & 5 deletions src/main/webapp/dataset.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -380,35 +380,35 @@
<div id="metrics-heading">
#{bundle['metrics.dataset.title']}
<span class="glyphicon glyphicon-question-sign tooltip-icon" data-toggle="tooltip" data-placement="auto top"
data-original-title="#{empty settingsServiceBean.get(':MDCLogPath') ? bundle['metrics.dataset.tip.default'] : bundle['metrics.dataset.tip.makedatacount']}"></span>
data-original-title="#{settingsWrapper.makeDataCountEnabled ? bundle['metrics.dataset.tip.makedatacount'] : bundle['metrics.dataset.tip.default']}"></span>
</div>
<div id="metrics-body">
<!-- Classic downloads -->
<div class="metrics-count-block" jsf:rendered="#{empty settingsServiceBean.get(':MDCLogPath')}">
<div class="metrics-count-block" jsf:rendered="#{!settingsWrapper.makeDataCountEnabled}">
<h:outputFormat value="{0} #{bundle['metrics.downloads']}">
<f:param value="#{guestbookResponseServiceBean.getCountGuestbookResponsesByDatasetId(DatasetPage.dataset.id)}"/>
</h:outputFormat>
<span class="glyphicon glyphicon-question-sign tooltip-icon"
data-toggle="tooltip" data-placement="auto top" data-original-title="#{bundle['metrics.dataset.downloads.default.tip']}"></span>
</div>
<!-- Make Data Count views -->
<div class="metrics-count-block" jsf:rendered="#{not empty settingsServiceBean.get(':MDCLogPath')}">
<div class="metrics-count-block" jsf:rendered="#{settingsWrapper.makeDataCountEnabled}">
<h:outputFormat value="{0} #{bundle['metrics.views']}">
<f:param value="#{datasetMetricsServiceBean.getMetrics(DatasetPage.dataset).getViewsTotal()}"/>
</h:outputFormat>
<span class="glyphicon glyphicon-question-sign tooltip-icon"
data-toggle="tooltip" data-placement="auto top" data-original-title="#{bundle['metrics.dataset.views.tip']}"></span>
</div>
<!-- Make Data Count downloads -->
<div class="metrics-count-block" jsf:rendered="#{not empty settingsServiceBean.get(':MDCLogPath')}">
<div class="metrics-count-block" jsf:rendered="#{settingsWrapper.makeDataCountEnabled}">
<h:outputFormat value="{0} #{bundle['metrics.downloads']}">
<f:param value="#{datasetMetricsServiceBean.getMetrics(DatasetPage.dataset).getDownloadsTotal()}"/>
</h:outputFormat>
<span class="glyphicon glyphicon-question-sign tooltip-icon"
data-toggle="tooltip" data-placement="auto top" data-original-title="#{bundle['metrics.dataset.downloads.makedatacount.tip']}"></span>
</div>
<!-- Make Data Count citations (DOIs only, not Handles) -->
<div class="metrics-count-block" jsf:rendered="#{true}">
<div class="metrics-count-block" jsf:rendered="#{settingsWrapper.makeDataCountEnabled and settingsWrapper.doiInstallation}">
<p:commandLink oncomplete="PF('citationsDialog').show();">
<h:outputFormat value="{0} #{bundle['metrics.citations']}">
<f:param value="#{fn:length(datasetExternalCitationsServiceBean.getDatasetExternalCitationsByDataset(DatasetPage.dataset))}"/>
Expand Down
6 changes: 3 additions & 3 deletions src/main/webapp/file.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -319,19 +319,19 @@
<div id="metrics-heading">
#{bundle['metrics.file.title']}
<span class="glyphicon glyphicon-question-sign tooltip-icon" data-toggle="tooltip" data-placement="auto top"
data-original-title="#{empty settingsServiceBean.get(':MDCLogPath') ? bundle['metrics.file.tip.default'] : bundle['metrics.file.tip.makedatacount']}"></span>
data-original-title="#{settingsWrapper.makeDataCountEnabled ? bundle['metrics.file.tip.makedatacount'] : bundle['metrics.file.tip.default']}"></span>
</div>
<div id="metrics-body">
<!-- Classic downloads -->
<div class="metrics-count-block" jsf:rendered="#{empty settingsServiceBean.get(':MDCLogPath')}">
<div class="metrics-count-block" jsf:rendered="#{!settingsWrapper.makeDataCountEnabled}">
<h:outputFormat value="{0} #{bundle['metrics.downloads']}">
<f:param value="#{guestbookResponseServiceBean.getCountGuestbookResponsesByDataFileId(FilePage.fileId)}"/>
</h:outputFormat>
<span class="glyphicon glyphicon-question-sign tooltip-icon"
data-toggle="tooltip" data-placement="auto top" data-original-title="#{bundle['metrics.file.downloads.tip']}"></span>
</div>
<!-- Make Data Count downloads -->
<div class="metrics-count-block" jsf:rendered="#{not empty settingsServiceBean.get(':MDCLogPath')}">
<div class="metrics-count-block" jsf:rendered="#{settingsWrapper.makeDataCountEnabled}">
<h:outputFormat value="{0} #{bundle['metrics.downloads']}">
<f:param value="#{guestbookResponseServiceBean.getCountGuestbookResponsesByDataFileId(FilePage.fileId)}"/>
</h:outputFormat>
Expand Down

0 comments on commit 0b4d21f

Please sign in to comment.