From e9b969a63472bf9a4a9f4381042ca785f15b81fc Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Fri, 17 Jan 2020 17:55:31 -0500 Subject: [PATCH 1/6] MDC handle legacy counts --- .../iq/dataverse/GuestbookResponseServiceBean.java | 12 +++++++++++- .../edu/harvard/iq/dataverse/SettingsWrapper.java | 10 ++++++++++ .../iq/dataverse/settings/SettingsServiceBean.java | 3 ++- src/main/java/propertyFiles/Bundle.properties | 3 +++ src/main/webapp/dataset.xhtml | 7 +++++++ src/main/webapp/file.xhtml | 2 +- 6 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/GuestbookResponseServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/GuestbookResponseServiceBean.java index 7ac791acf3c..a0d41741ae0 100644 --- a/src/main/java/edu/harvard/iq/dataverse/GuestbookResponseServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/GuestbookResponseServiceBean.java @@ -12,6 +12,7 @@ import java.io.IOException; import java.io.OutputStream; import java.text.SimpleDateFormat; +import java.time.LocalDate; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; @@ -936,8 +937,17 @@ public Long getCountGuestbookResponsesByDataFileId(Long dataFileId) { } public Long getCountGuestbookResponsesByDatasetId(Long datasetId) { + return getCountGuestbookResponsesByDatasetId(datasetId, null); + } + + public Long getCountGuestbookResponsesByDatasetId(Long datasetId, LocalDate date) { // dataset id is null, will return 0 - Query query = em.createNativeQuery("select count(o.id) from GuestbookResponse o where o.dataset_id = " + datasetId); + Query query; + if(date != null) { + query = em.createNativeQuery("select count(o.id) from GuestbookResponse o where o.dataset_id = " + datasetId + " and responsetime < '" + date.toString() + "'"); + }else { + query = em.createNativeQuery("select count(o.id) from GuestbookResponse o where o.dataset_id = " + datasetId); + } return (Long) query.getSingleResult(); } diff --git a/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java b/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java index 7747d4b207a..ed8c9c0e2f7 100644 --- a/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java +++ b/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java @@ -12,6 +12,7 @@ import edu.harvard.iq.dataverse.util.MailUtil; import edu.harvard.iq.dataverse.util.StringUtil; import edu.harvard.iq.dataverse.util.SystemConfig; +import java.time.LocalDate; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; @@ -254,7 +255,16 @@ public boolean isDoiInstallation() { public boolean isMakeDataCountDisplayEnabled() { boolean safeDefaultIfKeyNotFound = (getValueForKey(SettingsServiceBean.Key.MDCLogPath)!=null); //Backward compatible return isTrueForKey(SettingsServiceBean.Key.DisplayMDCMetrics, safeDefaultIfKeyNotFound); + } + public LocalDate getMDCStartDate() { + String date = getValueForKey(SettingsServiceBean.Key.MDCStartDate); + LocalDate ld=null; + if(date!=null) { + ld = LocalDate.parse(date); + } + return ld; + } } diff --git a/src/main/java/edu/harvard/iq/dataverse/settings/SettingsServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/settings/SettingsServiceBean.java index 473bea561b4..9608f42b532 100644 --- a/src/main/java/edu/harvard/iq/dataverse/settings/SettingsServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/settings/SettingsServiceBean.java @@ -397,9 +397,10 @@ Whether Harvesting (OAI) service is enabled */ InheritParentRoleAssignments, - /** Make Data Count Logging and Display */ + /** Make Data Count Logging, Display, and Start Date */ MDCLogPath, DisplayMDCMetrics, + MDCStartDate, /** * Allow CORS flag (true or false). It is true by default diff --git a/src/main/java/propertyFiles/Bundle.properties b/src/main/java/propertyFiles/Bundle.properties index fc88691d9cc..92abfcc5d28 100755 --- a/src/main/java/propertyFiles/Bundle.properties +++ b/src/main/java/propertyFiles/Bundle.properties @@ -1235,13 +1235,16 @@ metrics.dataset.tip.makedatacount=Metrics collected using User Guide. diff --git a/src/main/webapp/dataset.xhtml b/src/main/webapp/dataset.xhtml index db7620bab71..88c6691c620 100644 --- a/src/main/webapp/dataset.xhtml +++ b/src/main/webapp/dataset.xhtml @@ -415,6 +415,13 @@ + + + + + ) +
diff --git a/src/main/webapp/file.xhtml b/src/main/webapp/file.xhtml index 45c5b6cb452..d824551037d 100644 --- a/src/main/webapp/file.xhtml +++ b/src/main/webapp/file.xhtml @@ -330,7 +330,7 @@ + data-toggle="tooltip" data-placement="auto top" data-original-title="#{bundle['metrics.file.downloads.nonmdc.tip']}">
From 5aad62597ee7f76b6c417ac68b5ab1fd099f2fbd Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Fri, 17 Jan 2020 18:05:25 -0500 Subject: [PATCH 2/6] remove extra paren for 1 download case --- src/main/java/propertyFiles/Bundle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/propertyFiles/Bundle.properties b/src/main/java/propertyFiles/Bundle.properties index 92abfcc5d28..5e9dfc7fd9c 100755 --- a/src/main/java/propertyFiles/Bundle.properties +++ b/src/main/java/propertyFiles/Bundle.properties @@ -1244,7 +1244,7 @@ metrics.file.downloads.tip=Total downloads of this file. 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 data project may be larger than total downloads reported for a data project. metrics.views={0, choice, 0#Views|1#View|2#Views} metrics.downloads={0, choice, 0#Downloads|1#Download|2#Downloads} -metrics.downloads.nonMDC={0, choice, 0#|1# (+ 1 pre-MDC)|2< (+ {0} pre-MDC } +metrics.downloads.nonMDC={0, choice, 0#|1# (+ 1 pre-MDC |2< (+ {0} pre-MDC } metrics.citations={0, choice, 0#Citations|1#Citation|2#Citations} metrics.citations.dialog.header=Dataset Citations 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 User Guide. From 0e16e58d36c9f741ee7afa76c348cf023834e6c1 Mon Sep 17 00:00:00 2001 From: qqmyers Date: Fri, 17 Jan 2020 18:13:35 -0500 Subject: [PATCH 3/6] use standard terms --- src/main/java/propertyFiles/Bundle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/propertyFiles/Bundle.properties b/src/main/java/propertyFiles/Bundle.properties index 5e9dfc7fd9c..91c283d0364 100755 --- a/src/main/java/propertyFiles/Bundle.properties +++ b/src/main/java/propertyFiles/Bundle.properties @@ -1241,7 +1241,7 @@ metrics.file.title=File Metrics metrics.file.tip.default=Metrics for this individual file. metrics.file.tip.makedatacount=Individual file downloads are tracked in Dataverse but are not reported as part of the Make Data Count standard. metrics.file.downloads.tip=Total downloads of this file. -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 data project may be larger than total downloads reported for a data project. +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. metrics.views={0, choice, 0#Views|1#View|2#Views} metrics.downloads={0, choice, 0#Downloads|1#Download|2#Downloads} metrics.downloads.nonMDC={0, choice, 0#|1# (+ 1 pre-MDC |2< (+ {0} pre-MDC } From d7a4939742128705046886b8a6702e68236e8260 Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Wed, 5 Feb 2020 17:19:10 -0500 Subject: [PATCH 4/6] MDC display updates Conflicts: src/main/java/propertyFiles/Bundle.properties --- src/main/java/propertyFiles/Bundle.properties | 6 ++++-- src/main/webapp/dataset.xhtml | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/propertyFiles/Bundle.properties b/src/main/java/propertyFiles/Bundle.properties index 5e9dfc7fd9c..1193e2535a6 100755 --- a/src/main/java/propertyFiles/Bundle.properties +++ b/src/main/java/propertyFiles/Bundle.properties @@ -1231,11 +1231,13 @@ metrics.title=Metrics metrics.title.tip=View more metrics information metrics.dataset.title=Dataset Metrics metrics.dataset.tip.default=Aggregated metrics for this dataset. +metrics.dataset.makedatacount.title=Make Data Count (MDC) Metrics +metrics.dataset.makedatacount.since=Since metrics.dataset.tip.makedatacount=Metrics collected using Make Data Count standards. -metrics.dataset.views.tip=Dataset views are combined with both aggregated file views and file downloads. +metrics.dataset.views.tip=Aggregate of views of the dataset landing page, file views, and file downloads. metrics.dataset.downloads.default.tip=Total aggregated downloads of files in this dataset. metrics.dataset.downloads.makedatacount.tip=Each file downloaded is counted as 1, and added to the total download count. -metrics.dataset.downloads.premakedatacount.tip=Downloads prior to when MDC was enabled. These do not have the same filtering and detail as MDC metrics. +metrics.dataset.downloads.premakedatacount.tip=Downloads prior to enabling MDC. Counts do not have the same filtering and detail as MDC metrics. metrics.dataset.citations.tip=Click for a list of citation URLs. metrics.file.title=File Metrics metrics.file.tip.default=Metrics for this individual file. diff --git a/src/main/webapp/dataset.xhtml b/src/main/webapp/dataset.xhtml index 88c6691c620..fda19a7ef4d 100644 --- a/src/main/webapp/dataset.xhtml +++ b/src/main/webapp/dataset.xhtml @@ -381,7 +381,7 @@
- #{bundle['metrics.dataset.title']} + #{settingsWrapper.makeDataCountDisplayEnabled ? bundle['metrics.dataset.makedatacount.title'] : bundle['metrics.dataset.title']} @@ -389,7 +389,9 @@ +
#{bundle['metrics.dataset.makedatacount.since']} ##{!settingsWrapper.getMDCStartDate().toString()}
+
From 83d211873a434d570ac535f3bada737c1f1423ec Mon Sep 17 00:00:00 2001 From: Jim Myers Date: Wed, 5 Feb 2020 17:38:46 -0500 Subject: [PATCH 5/6] typo / style fixes Conflicts: src/main/java/propertyFiles/Bundle.properties --- src/main/java/propertyFiles/Bundle.properties | 2 +- src/main/webapp/dataset.xhtml | 2 +- src/main/webapp/resources/css/structure.css | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/propertyFiles/Bundle.properties b/src/main/java/propertyFiles/Bundle.properties index 1193e2535a6..80423885ebd 100755 --- a/src/main/java/propertyFiles/Bundle.properties +++ b/src/main/java/propertyFiles/Bundle.properties @@ -1232,7 +1232,7 @@ metrics.title.tip=View more metrics information metrics.dataset.title=Dataset Metrics metrics.dataset.tip.default=Aggregated metrics for this dataset. metrics.dataset.makedatacount.title=Make Data Count (MDC) Metrics -metrics.dataset.makedatacount.since=Since +metrics.dataset.makedatacount.since=since metrics.dataset.tip.makedatacount=Metrics collected using Make Data Count standards. metrics.dataset.views.tip=Aggregate of views of the dataset landing page, file views, and file downloads. metrics.dataset.downloads.default.tip=Total aggregated downloads of files in this dataset. diff --git a/src/main/webapp/dataset.xhtml b/src/main/webapp/dataset.xhtml index fda19a7ef4d..64653c1e559 100644 --- a/src/main/webapp/dataset.xhtml +++ b/src/main/webapp/dataset.xhtml @@ -389,7 +389,7 @@ -
#{bundle['metrics.dataset.makedatacount.since']} ##{!settingsWrapper.getMDCStartDate().toString()}
+
#{bundle['metrics.dataset.makedatacount.since']} #{settingsWrapper.getMDCStartDate().toString()}
diff --git a/src/main/webapp/resources/css/structure.css b/src/main/webapp/resources/css/structure.css index b5c764c1e15..ddfb056d86c 100644 --- a/src/main/webapp/resources/css/structure.css +++ b/src/main/webapp/resources/css/structure.css @@ -598,6 +598,7 @@ div[id$='roleDisplay'] span.label, div[id$='roleDetails'] span.label {display:in #metrics-content {color:#333;background:#fff;padding:8px 10px;} #metrics-heading {font-weight:bold;color:#333;background:#eee;padding:8px 10px;} +#metrics-heading-subtitle {font-weight:normal;font-size:smaller;} #metrics-body {border:1px solid #EEE;border-top-width:0;padding:8px 10px;} #metrics-block .metrics-count-block:not(:last-child) {margin-bottom:.5em;padding-bottom:.5em;border-bottom:1px solid #EEE} From 61e04ad0a61a902515d2ee043697488aedbed2df Mon Sep 17 00:00:00 2001 From: landreev Date: Tue, 30 May 2023 10:49:18 -0400 Subject: [PATCH 6/6] Simple release note --- doc/release-notes/6542-mdc-legacy-counts.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 doc/release-notes/6542-mdc-legacy-counts.md diff --git a/doc/release-notes/6542-mdc-legacy-counts.md b/doc/release-notes/6542-mdc-legacy-counts.md new file mode 100644 index 00000000000..1f439747a08 --- /dev/null +++ b/doc/release-notes/6542-mdc-legacy-counts.md @@ -0,0 +1,3 @@ +###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. + +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.