Skip to content

Commit

Permalink
Use Datacite metrics when displaying view/download counts (#1094)
Browse files Browse the repository at this point in the history
Co-authored-by: Jake Rosenberg <[email protected]>
  • Loading branch information
jarosenb and Jake Rosenberg authored Sep 13, 2023
1 parent 2817aa8 commit d29e814
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ <h3 class="text-center">
<div style="padding-bottom: 5px;">
<span ng-if="$ctrl.readOnly">
<span style="background-color: #ECE4BF;">
{{ $ctrl.cumDoiMetrics[mission.value.dois].fileDownloads || 0 }} Downloads
{{ $ctrl.metricDisplay($ctrl.downloadCounts[mission.value.dois]) }} Downloads
</span>
&nbsp;&nbsp;
<span style="background-color: #ECE4BF;">
{{ $ctrl.cumDoiMetrics[mission.value.dois].filePreviews || 0}} Views
{{ $ctrl.metricDisplay($ctrl.viewCounts[mission.value.dois]) }} Views
</span>
&nbsp;&nbsp;
<span style="background-color: #ECE4BF;">
{{ $ctrl.citationCounts[mission.value.dois] || 0}} Citations
{{ $ctrl.metricDisplay($ctrl.citationCounts[mission.value.dois]) }} Citations
</span>
&nbsp;&nbsp;
<span>
Expand Down Expand Up @@ -310,15 +310,15 @@ <h3 class="text-center">
<div style="padding-bottom: 5px;">
<span ng-if="$ctrl.readOnly">
<span style="background-color: #ECE4BF;">
{{ $ctrl.cumDoiMetrics[mission.value.dois].fileDownloads || 0 }} Downloads
{{ $ctrl.metricDisplay($ctrl.downloadCounts[mission.value.dois]) }} Downloads
</span>
&nbsp;&nbsp;
<span style="background-color: #ECE4BF;">
{{ $ctrl.cumDoiMetrics[mission.value.dois].filePreviews || 0}} Views
{{ $ctrl.metricDisplay($ctrl.viewCounts[mission.value.dois]) }} Views
</span>
&nbsp;&nbsp;
<span style="background-color: #ECE4BF;">
{{ $ctrl.citationCounts[mission.value.dois] || 0}} Citations
{{ $ctrl.metricDisplay($ctrl.citationCounts[mission.value.dois]) }} Citations
</span>
&nbsp;&nbsp;
<span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ <h3 class="text-center">
<div style="padding-bottom: 5px;">
<span ng-if="$ctrl.readOnly">
<span style="background-color: #ECE4BF;">
{{ $ctrl.cumDoiMetrics[hybsim.value.dois].fileDownloads || 0 }} Downloads
{{ $ctrl.metricDisplay($ctrl.downloadCounts[hybsim.value.dois])}} Downloads
</span>
&nbsp;&nbsp;
<span style="background-color: #ECE4BF;">
{{ $ctrl.cumDoiMetrics[hybsim.value.dois].filePreviews || 0}} Views
{{ $ctrl.metricDisplay($ctrl.viewCounts[hybsim.value.dois])}} Views
</span>
&nbsp;&nbsp;
<span style="background-color: #ECE4BF;">
{{ $ctrl.citationCounts[hybsim.value.dois] || 0}} Citations
{{ $ctrl.metricDisplay($ctrl.citationCounts[hybsim.value.dois])}} Citations
</span>
&nbsp;&nbsp;
<span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,15 @@ <h3 class="text-center">
<div style="padding-bottom: 5px;">
<span ng-if="$ctrl.readOnly">
<span style="background-color: #ECE4BF;">
{{ $ctrl.cumDoiMetrics[simulation.value.dois].fileDownloads || 0 }} Downloads
{{ $ctrl.metricDisplay($ctrl.downloadCounts[simulation.value.dois]) }} Downloads
</span>
&nbsp;&nbsp;
<span style="background-color: #ECE4BF;">
{{ $ctrl.cumDoiMetrics[simulation.value.dois].filePreviews || 0}} Views
{{ $ctrl.metricDisplay($ctrl.viewCounts[simulation.value.dois])}} Views
</span>
&nbsp;&nbsp;
<span style="background-color: #ECE4BF;">
{{ $ctrl.citationCounts[simulation.value.dois] || 0}} Citations
{{ $ctrl.metricDisplay($ctrl.citationCounts[simulation.value.dois])}} Citations
</span>
&nbsp;&nbsp;
<span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ <h3 class="text-center">
<div style="padding-bottom: 5px;">
<span ng-if="$ctrl.readOnly">
<span style="background-color: #ECE4BF;">
{{ $ctrl.cumDoiMetrics[experiment.value.dois].fileDownloads || 0 }} Downloads
{{ $ctrl.metricDisplay($ctrl.downloadCounts[experiment.value.dois]) }} Downloads
</span>
&nbsp;&nbsp;
<span style="background-color: #ECE4BF;">
{{ $ctrl.cumDoiMetrics[experiment.value.dois].filePreviews || 0}} Views
{{ $ctrl.metricDisplay($ctrl.viewCounts[experiment.value.dois]) }} Views
</span>
&nbsp;&nbsp;
<span style="background-color: #ECE4BF;">
{{ $ctrl.citationCounts[experiment.value.dois] || 0}} Citations
{{ $ctrl.metricDisplay($ctrl.citationCounts[experiment.value.dois]) }} Citations
</span>
&nbsp;&nbsp;
<span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ class PublishedViewCtrl {
});
});
}
this.citationCounts = {}
this.citationCounts = {};
this.viewCounts = {};
this.downloadCounts = {};
this.projId = this.$stateParams.filePath.replace(/^\/+/, '').split('/')[0];
this.versions = this.prepVersions(this.publication);
this.selectedVersion = this.publication.revision || 1;
Expand Down Expand Up @@ -315,6 +317,9 @@ class PublishedViewCtrl {
this.doi = this.doiList[ent.uuid];
});
}
if (this.project.value.projectType === 'other') {
this.doiList[this.project.uuid] = {doi: this.project.value.dois[0]};
}
if (this.doiList) {
const dataciteRequests = Object.values(this.doiList).map(({ doi }) => {
return this.$http.get(`/api/publications/data-cite/${doi}`);
Expand All @@ -328,6 +333,8 @@ class PublishedViewCtrl {
citations.forEach((cite) => {
const doiObj = Object.values(this.doiList).find((x) => x.doi === cite.doi);
this.citationCounts[cite.doi] = cite.citationCount;
this.downloadCounts[cite.doi] = cite.downloadCount;
this.viewCounts[cite.doi] = cite.viewCount;
doiObj.created = cite.created;
});
});
Expand All @@ -348,6 +355,12 @@ class PublishedViewCtrl {
);
}

metricDisplay(metric) {
if (metric === 0) return 0;
if (metric) return metric;
return "--";
}

prepVersions(publication) {
// returns a list of publication versions
if (publication.latestRevision) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@
<div style="padding-bottom: 5px;">
<span ng-if="$ctrl.readOnly">
<span style="background-color: #ECE4BF;">
{{ $ctrl.cumMetrics.otherTotal || 0 }} Downloads
{{ $ctrl.metricDisplay($ctrl.downloadCounts[$ctrl.project.value.dois[0]]) }} Downloads
</span>
&nbsp;&nbsp;
<span style="background-color: #ECE4BF;">
{{ $ctrl.cumMetrics.filePreviews || 0}} Views
<span style="background-color: #ECE4BF;">
{{ $ctrl.metricDisplay($ctrl.viewCounts[$ctrl.project.value.dois[0]]) }} Views
</span>
&nbsp;&nbsp;
<span style="background-color: #ECE4BF;">
{{ $ctrl.citationCounts[experiment.value.dois] || 0}} Citations
<span style="background-color: #ECE4BF;">
{{ $ctrl.metricDisplay($ctrl.citationCounts[$ctrl.project.value.dois[0]]) }} Citations
</span>
&nbsp;&nbsp;
<span ng-if="$ctrl.readOnly">
Expand Down

0 comments on commit d29e814

Please sign in to comment.