Skip to content

Commit fd190a3

Browse files
authored
Merge pull request #6543 from QualitativeDataRepository/IQSS/6542
MDC handle legacy counts
2 parents 2d29201 + 791319e commit fd190a3

8 files changed

Lines changed: 76 additions & 21 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
###For installations using MDC (Make Data Count), it is now possible to display both the MDC metrics and the legacy access counts, generated before MDC was enabled.
2+
3+
This is enabled via the new setting `:MDCStartDate` that specifies the cutoff date. If a dataset has any legacy access counts collected prior to that date, those numbers will be displayed in addition to the any MDC numbers recorded since then.

src/main/java/edu/harvard/iq/dataverse/GuestbookResponseServiceBean.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.io.IOException;
1313
import java.io.OutputStream;
1414
import java.text.SimpleDateFormat;
15+
import java.time.LocalDate;
1516
import java.util.ArrayList;
1617
import java.util.Calendar;
1718
import java.util.Date;
@@ -910,8 +911,17 @@ public Long getCountGuestbookResponsesByDataFileId(Long dataFileId) {
910911
}
911912

912913
public Long getCountGuestbookResponsesByDatasetId(Long datasetId) {
914+
return getCountGuestbookResponsesByDatasetId(datasetId, null);
915+
}
916+
917+
public Long getCountGuestbookResponsesByDatasetId(Long datasetId, LocalDate date) {
913918
// dataset id is null, will return 0
914-
Query query = em.createNativeQuery("select count(o.id) from GuestbookResponse o where o.dataset_id = " + datasetId);
919+
Query query;
920+
if(date != null) {
921+
query = em.createNativeQuery("select count(o.id) from GuestbookResponse o where o.dataset_id = " + datasetId + " and responsetime < '" + date.toString() + "'");
922+
}else {
923+
query = em.createNativeQuery("select count(o.id) from GuestbookResponse o where o.dataset_id = " + datasetId);
924+
}
915925
return (Long) query.getSingleResult();
916926
}
917927

src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,16 @@ public boolean isDataCiteInstallation() {
464464
public boolean isMakeDataCountDisplayEnabled() {
465465
boolean safeDefaultIfKeyNotFound = (getValueForKey(SettingsServiceBean.Key.MDCLogPath)!=null); //Backward compatible
466466
return isTrueForKey(SettingsServiceBean.Key.DisplayMDCMetrics, safeDefaultIfKeyNotFound);
467+
}
467468

469+
public LocalDate getMDCStartDate() {
470+
String date = getValueForKey(SettingsServiceBean.Key.MDCStartDate);
471+
LocalDate ld=null;
472+
if(date!=null) {
473+
ld = LocalDate.parse(date);
474+
}
475+
return ld;
476+
468477
}
469478

470479
public boolean displayChronologicalDateFacets() {

src/main/java/edu/harvard/iq/dataverse/settings/SettingsServiceBean.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,10 @@ Whether Harvesting (OAI) service is enabled
406406
*/
407407
InheritParentRoleAssignments,
408408

409-
/** Make Data Count Logging and Display */
409+
/** Make Data Count Logging, Display, and Start Date */
410410
MDCLogPath,
411411
DisplayMDCMetrics,
412+
MDCStartDate,
412413

413414
/**
414415
* Allow CORS flag (true or false). It is true by default

src/main/java/propertyFiles/Bundle.properties

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1406,17 +1406,22 @@ metrics.title=Metrics
14061406
metrics.title.tip=View more metrics information
14071407
metrics.dataset.title=Dataset Metrics
14081408
metrics.dataset.tip.default=Aggregated metrics for this dataset.
1409+
metrics.dataset.makedatacount.title=Make Data Count (MDC) Metrics
1410+
metrics.dataset.makedatacount.since=since
14091411
metrics.dataset.tip.makedatacount=Metrics collected using <a href="https://makedatacount.org/counter-code-of-practice-for-research-data/" target="_blank" rel="noopener"/>Make Data Count</a> standards.
1410-
metrics.dataset.views.tip=Dataset views are combined with both aggregated file views and file downloads.
1412+
metrics.dataset.views.tip=Aggregate of views of the dataset landing page, file views, and file downloads.
14111413
metrics.dataset.downloads.default.tip=Total aggregated downloads of files in this dataset.
14121414
metrics.dataset.downloads.makedatacount.tip=Each file downloaded is counted as 1, and added to the total download count.
1415+
metrics.dataset.downloads.premakedatacount.tip=Downloads prior to enabling MDC. Counts do not have the same filtering and detail as MDC metrics.
14131416
metrics.dataset.citations.tip=Click for a list of citation URLs.
14141417
metrics.file.title=File Metrics
14151418
metrics.file.tip.default=Metrics for this individual file.
14161419
metrics.file.tip.makedatacount=Individual file downloads are tracked in Dataverse but are not reported as part of the Make Data Count standard.
14171420
metrics.file.downloads.tip=Total downloads of this file.
1421+
metrics.file.downloads.nonmdc.tip=Total downloads. Due to differences between MDC and Dataverse's internal tracking, the sum of these for all files in a dataset may be larger than total downloads reported for a dataset.
14181422
metrics.views={0, choice, 0#Views|1#View|2#Views}
14191423
metrics.downloads={0, choice, 0#Downloads|1#Download|2#Downloads}
1424+
metrics.downloads.nonMDC={0, choice, 0#|1# (+ 1 pre-MDC |2< (+ {0} pre-MDC }
14201425
metrics.citations={0, choice, 0#Citations|1#Citation|2#Citations}
14211426
metrics.citations.dialog.header=Dataset Citations
14221427
metrics.citations.dialog.help=Citations for this dataset are retrieved from Crossref via DataCite using Make Data Count standards. For more information about dataset metrics, please refer to the <a href="{0}/{1}/user/dataset-management.html#dataset-metrics-and-make-data-count" title="Dataset Metrics and Make Data Count - Dataverse User Guide" target="_blank">User Guide</a>.

src/main/webapp/dataset.xhtml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,15 +522,17 @@
522522
<!-- Metrics -->
523523
<div id="metrics-block">
524524
<div id="metrics-heading">
525-
#{bundle['metrics.dataset.title']}
525+
#{settingsWrapper.makeDataCountDisplayEnabled ? bundle['metrics.dataset.makedatacount.title'] : bundle['metrics.dataset.title']}
526526
<ui:fragment rendered="#{!settingsWrapper.makeDataCountDisplayEnabled}">
527527
<span class="glyphicon glyphicon-question-sign tooltip-icon" data-toggle="tooltip" data-placement="auto top"
528528
data-trigger="hover" data-original-title="#{bundle['metrics.dataset.tip.default']}"></span>
529529
</ui:fragment>
530530
<ui:fragment rendered="#{settingsWrapper.makeDataCountDisplayEnabled}">
531531
<a tabindex="0" role="button" class="glyphicon glyphicon-question-sign tooltip-icon" data-toggle="popover" data-placement="auto top"
532532
data-trigger="focus" data-html="true" data-content="#{bundle['metrics.dataset.tip.makedatacount']}"></a>
533+
<div id="metrics-heading-subtitle">#{bundle['metrics.dataset.makedatacount.since']} #{settingsWrapper.getMDCStartDate().toString()}</div>
533534
</ui:fragment>
535+
534536
</div>
535537
<div id="metrics-body">
536538
<!-- Classic downloads -->
@@ -556,6 +558,13 @@
556558
</h:outputFormat>
557559
<span class="glyphicon glyphicon-question-sign tooltip-icon"
558560
data-toggle="tooltip" data-placement="auto top" data-original-title="#{bundle['metrics.dataset.downloads.makedatacount.tip']}"></span>
561+
<span jsf:rendered="#{settingsWrapper.getMDCStartDate()!=null}">
562+
<h:outputFormat value="#{bundle['metrics.downloads.nonMDC']}">
563+
<f:param value="#{guestbookResponseServiceBean.getCountGuestbookResponsesByDatasetId(DatasetPage.dataset.id, settingsWrapper.getMDCStartDate())}"/>
564+
</h:outputFormat>
565+
<span jsf:rendered="#{guestbookResponseServiceBean.getCountGuestbookResponsesByDatasetId(DatasetPage.dataset.id, settingsWrapper.getMDCStartDate()) > 0}" class="glyphicon glyphicon-question-sign tooltip-icon"
566+
data-toggle="tooltip" data-placement="auto top" data-original-title="#{bundle['metrics.dataset.downloads.premakedatacount.tip']}"></span>)
567+
</span>
559568
</div>
560569
<!-- Make Data Count citations (DOIs only, not Handles) -->
561570
<div class="metrics-count-block" jsf:rendered="#{settingsWrapper.makeDataCountDisplayEnabled and settingsWrapper.doiInstallation}">

src/main/webapp/file.xhtml

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -284,22 +284,39 @@
284284
data-trigger="focus" data-html="true" data-content="#{bundle['metrics.file.tip.makedatacount']}"></a>
285285
</ui:fragment>
286286
</div>
287-
<div id="metrics-body">
288-
<!-- Classic downloads -->
289-
<div class="metrics-count-block" jsf:rendered="#{!settingsWrapper.makeDataCountDisplayEnabled}">
290-
<h:outputFormat value="{0} #{bundle['metrics.downloads']}">
291-
<f:param value="#{guestbookResponseServiceBean.getCountGuestbookResponsesByDataFileId(FilePage.fileId)}"/>
292-
</h:outputFormat>
293-
<span class="glyphicon glyphicon-question-sign tooltip-icon"
294-
data-toggle="tooltip" data-placement="auto top" data-original-title="#{bundle['metrics.file.downloads.tip']}"></span>
295-
</div>
296-
<!-- Make Data Count downloads -->
297-
<div class="metrics-count-block" jsf:rendered="#{settingsWrapper.makeDataCountDisplayEnabled}">
298-
<h:outputFormat value="{0} #{bundle['metrics.downloads']}">
299-
<f:param value="#{guestbookResponseServiceBean.getCountGuestbookResponsesByDataFileId(FilePage.fileId)}"/>
300-
</h:outputFormat>
301-
<span class="glyphicon glyphicon-question-sign tooltip-icon"
302-
data-toggle="tooltip" data-placement="auto top" data-original-title="#{bundle['metrics.file.downloads.tip']}"></span>
287+
<!-- END DATASET CITATION -->
288+
<!-- Metrics -->
289+
<div class="col-sm-3">
290+
<div id="metrics-block" jsf:rendered="#{!(widgetWrapper.widgetView or FilePage.fileMetadata.dataFile.filePackage or FilePage.fileMetadata.datasetVersion.deaccessioned)}">
291+
<div id="metrics-heading">
292+
#{bundle['metrics.file.title']}
293+
<ui:fragment rendered="#{!settingsWrapper.makeDataCountDisplayEnabled}">
294+
<span class="glyphicon glyphicon-question-sign tooltip-icon" data-toggle="tooltip" data-placement="auto top"
295+
data-trigger="hover" data-original-title="#{bundle['metrics.dataset.tip.default']}"></span>
296+
</ui:fragment>
297+
<ui:fragment rendered="#{settingsWrapper.makeDataCountDisplayEnabled}">
298+
<a tabindex="0" role="button" class="glyphicon glyphicon-question-sign tooltip-icon" data-toggle="popover" data-placement="auto top"
299+
data-trigger="focus" data-html="true" data-content="#{bundle['metrics.dataset.tip.makedatacount']}"></a>
300+
</ui:fragment>
301+
</div>
302+
<div id="metrics-body">
303+
<!-- Classic downloads -->
304+
<div class="metrics-count-block" jsf:rendered="#{!settingsWrapper.makeDataCountDisplayEnabled}">
305+
<h:outputFormat value="{0} #{bundle['metrics.downloads']}">
306+
<f:param value="#{guestbookResponseServiceBean.getCountGuestbookResponsesByDataFileId(FilePage.fileId)}"/>
307+
</h:outputFormat>
308+
<span class="glyphicon glyphicon-question-sign tooltip-icon"
309+
data-toggle="tooltip" data-placement="auto top" data-original-title="#{bundle['metrics.file.downloads.tip']}"></span>
310+
</div>
311+
<!-- Make Data Count downloads -->
312+
<div class="metrics-count-block" jsf:rendered="#{settingsWrapper.makeDataCountDisplayEnabled}">
313+
<h:outputFormat value="{0} #{bundle['metrics.downloads']}">
314+
<f:param value="#{guestbookResponseServiceBean.getCountGuestbookResponsesByDataFileId(FilePage.fileId)}"/>
315+
</h:outputFormat>
316+
<span class="glyphicon glyphicon-question-sign tooltip-icon"
317+
data-toggle="tooltip" data-placement="auto top" data-original-title="#{bundle['metrics.file.downloads.nonmdc.tip']}"></span>
318+
</div>
319+
</div>
303320
</div>
304321
</div>
305322
</div>

src/main/webapp/resources/css/structure.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,8 @@ div[id$='roleDisplay'] span.label, div[id$='roleDetails'] span.label {display:in
578578
#metrics-content {color:#333;background:#fff;padding:8px 10px;}
579579
/* -- NEW LAYOUT, DATASET + FILE -- */
580580
#metrics-block {border:0; margin-top:6px;}
581-
#metrics-body {border:1px solid #EEE;border-width:1px 0 0 0;padding:8px 0;}
581+
#metrics-heading-subtitle {font-weight:normal;font-size:smaller;}
582+
#metrics-body {border:1px solid #EEE;border-top-width:0;padding:8px 10px;}
582583
#metrics-block .metrics-count-block:not(:last-child) {margin-bottom:.5em;padding-bottom:.5em;border-bottom:1px solid #EEE}
583584

584585
/* -------- SHARRRE -------- */

0 commit comments

Comments
 (0)