Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a bug that stopped metrics from displaying for repository authors #4180

Merged
merged 2 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/repository/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,17 +245,23 @@ def repository_author_article(request, preprint_id):
stage__in=models.SUBMITTED_STAGES,
repository=request.repository,
)
metrics_summary = repository_logic.metrics_summary([preprint])

template = 'admin/repository/author_article.html'
context = {
'preprint': preprint,
'metrics_summary': metrics_summary,
'preprint_journals': repository_logic.get_list_of_preprint_journals(),
'pending_updates': models.VersionQueue.objects.filter(
preprint=preprint,
date_decision__isnull=True,
),
'views': models.PreprintAccess.objects.filter(
preprint=preprint,
file__isnull=True,
).count(),
'downloads': models.PreprintAccess.objects.filter(
preprint=preprint,
file__isnull=False,
).count(),
}

return render(request, template, context)
Expand Down
31 changes: 0 additions & 31 deletions src/templates/admin/elements/repository/author_metrics_chart.html

This file was deleted.

43 changes: 22 additions & 21 deletions src/templates/admin/repository/author_article.html
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,27 @@ <h2>Dates</h2>
{% endfor %}
</table>
</div>
<div class="title-area">
<h2>Metrics</h2>
</div>
<div class="content">
<p>Views track how often the {{ request.repository.object_name }} page has been visited, while Downloads record the number of times a
{{ request.repository.object_name }}'s file has been downloaded.</p>
<table class="table">
<tr>
<th>Metric Type</th>
<th>Total</th>
</tr>
<tr>
<td>Views</td>
<td>{{ views }}</td>
</tr>
<tr>
<td>Downloads</td>
<td>{{ downloads }}</td>
</tr>
</table>
</div>
<div class="title-area">
<h2>Comments</h2>
</div>
Expand All @@ -161,7 +182,7 @@ <h2>Comments</h2>
</div>

<div class="row expanded" data-equalizer data-equalize-on="medium">
<div class="large-8 columns">
<div class="large-12 columns">
<div class="box" data-equalizer-watch>
<div class="title-area">
<h2>Files</h2>
Expand Down Expand Up @@ -259,22 +280,6 @@ <h2>Submit to Journal</h2>
</div>

</div>
<div class="large-4 columns">
<div class="box" data-equalizer-watch>
<div class="title-area">
<h2>Metrics this Month</h2>
</div>
<div class="content">
<canvas id="metrics_this_month_chart" width="400" height="300"></canvas>
</div>
<div class="title-area">
<h2>Metrics last Month</h2>
</div>
<div class="content">
<canvas id="metrics_last_month_chart" width="400" height="300"></canvas>
</div>
</div>
</div>
</div>

<div class="reveal" id="uploadbox" data-reveal data-animation-in="slide-in-up"
Expand Down Expand Up @@ -314,10 +319,6 @@ <h4><i class="fa fa-upload">&nbsp;</i>Update {{ request.repository.object_name }


{% block js %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.0/Chart.min.js"></script>
{% include "admin/elements/repository/author_metrics_chart.html" with chart_name='metrics_this_month_chart' downloads=metrics_summary.downloads_this_month views=metrics_summary.views_this_month %}
{% include "admin/elements/repository/author_metrics_chart.html" with chart_name='metrics_last_month_chart' downloads=metrics_summary.downloads_last_month views=metrics_summary.views_last_month %}

{% if modal %}
{% include "admin/elements/open_modal.html" with target=modal %}
{% endif %}
Expand Down