SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 7de69075 authored by Jean-Sébastien Caux's avatar Jean-Sébastien Caux
Browse files

Add basic country level authorships stats

parent 97fa64ca
No related branches found
No related tags found
No related merge requests found
{% load countries %}
{% get_country country as country_obj %}
<h2 class="highlight">Authoring stats for {{ country_obj.name }}&emsp;<i class="{{ country_obj.flag_css }}"></i></h2>
<table class="table">
<thead>
<tr>
<th></th>
<th style="text-align: right;">Publications count</th>
<th style="text-align: right;">Authorships count</th>
</tr>
</thead>
<tbody>
<tr class="bg-light">
<td>Cumulative</td>
<td style="text-align: right;">{{ cumulative.publications_count }}</td>
<td style="text-align: right;">{{ cumulative.authorships_count }}</td>
</tr>
{% for year, val in per_year.items %}
<tr>
<td>{{ year }}</td>
<td style="text-align: right;">{{ val.publications_count }}</td>
<td style="text-align: right;">{{ val.authorships_count }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% extends 'scipost/base.html' %}
{% load countries %}
{% load static %}
{% block meta_description %}{{ block.super }} authorship info{% endblock meta_description %}
{% block pagetitle %}: authorship info{% endblock pagetitle %}
{% block headsup %}
<link rel="stylesheet" href="{% static 'flags/sprite-hq.css' %}">
{% endblock headsup %}
{% block content %}
<div class="row">
<div class="col-12">
<h2>Country-Level Authorship Data</h2>
<div class="row mt-4">
<div class="col-lg-3">
<h3>Click on flag to view that country's data</h3>
</div>
<div class="col-lg-8">
<ul>
{% for code in countrycodes %}
{% get_country code as country_obj %}
<li style="display: inline-block;" class="m-1">
<a hx-get="{% url 'stats:_hx_country_level_authorships' country=code %}"
hx-target="#country_data"
>
<i class="{{ country_obj.flag_css }}"
data-bs-toggle="tooltip"
title="{{ country_obj.name }}"></i>
</a>
</li>
{% endfor %}
</ul>
</div>
</div>
<div id="country_data" class="mt-4"></div>
</div>
</div>
{% endblock content %}
......@@ -25,5 +25,15 @@ urlpatterns = [
views.statistics,
name="statistics",
),
path(
"country_level_authorships",
views.country_level_authorships,
name="country_level_authorships",
),
path(
"_hx_country_level_authorships/<slug:country>",
views._hx_country_level_authorships,
name="_hx_country_level_authorships",
),
path("statistics", views.statistics, name="statistics"),
]
......@@ -6,11 +6,45 @@ import datetime
from django.contrib.auth.decorators import permission_required
from django.shortcuts import get_object_or_404, render
from django.utils import timezone
from journals.models import Journal, Volume, Issue
from journals.models import Journal, Volume, Issue, Publication, PublicationAuthorsTable
from submissions.models import Submission
def country_level_authorships(request):
context = {}
context["countrycodes"] = list(set(
[item["authors__affiliations__country"]
for item in list(Publication.objects.all().values(
"authors__affiliations__country"
)) if item["authors__affiliations__country"]]))
context["countrycodes"].sort()
return render(request, "stats/country_level_authorships.html", context)
def _hx_country_level_authorships(request, country):
publications = Publication.objects.filter(authors__affiliations__country=country).distinct()
authorships = PublicationAuthorsTable.objects.filter(affiliations__country=country)
pubyears = [str(y) for y in range(int(timezone.now().strftime("%Y")), 2015, -1)]
context = {
"country": country,
"cumulative": {
"publications_count": publications.count(),
"authorships_count": authorships.count(),
},
"per_year": {}
}
for year in pubyears:
context["per_year"][year] = {
"publications_count": publications.filter(publication_date__year=year).count(),
"authorships_count": authorships.filter(
publication__publication_date__year=year
).count(),
}
return render(request, "stats/_hx_country_level_authorships.html", context)
@permission_required("scipost.can_view_statistics", raise_exception=True)
def statistics(
request, journal_doi_label=None, volume_nr=None, issue_nr=None, year=None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment