SciPost Code Repository

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

Add (distinct) authors count to stats, country filter to search

parent 7de69075
No related branches found
No related tags found
No related merge requests found
......@@ -26,4 +26,4 @@ class ExtraFilteredReadOnlyModelViewSet(viewsets.ReadOnlyModelViewSet):
querydict["%s__%s" % (field, lookup)] = param
query = query | Q(**querydict)
queryset = queryset.filter(query)
return queryset
return queryset.distinct()
......@@ -37,6 +37,12 @@ class PublicationPublicAPIFilterSet(df_filters.FilterSet):
"topics__name": [
"icontains",
],
"authors__affiliations__name": [
"icontains",
],
"authors__affiliations__country": [
"exact",
],
}
......@@ -70,4 +76,10 @@ class PublicationPublicSearchAPIFilterSet(df_filters.FilterSet):
"topics__name": [
"icontains",
],
"authors__affiliations__name": [
"icontains",
],
"authors__affiliations__country": [
"iexact",
],
}
......@@ -7,8 +7,9 @@
<thead>
<tr>
<th></th>
<th style="text-align: right;">Publications count</th>
<th style="text-align: right;">Authorships count</th>
<th style="text-align: right;">Publications</th>
<th style="text-align: right;">Authorships</th>
<th style="text-align: right;">Authors (distinct)</th>
</tr>
</thead>
<tbody>
......@@ -16,12 +17,14 @@
<td>Cumulative</td>
<td style="text-align: right;">{{ cumulative.publications_count }}</td>
<td style="text-align: right;">{{ cumulative.authorships_count }}</td>
<td style="text-align: right;">{{ cumulative.authors_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>
<td style="text-align: right;">{{ val.authors_count }}</td>
</tr>
{% endfor %}
</tbody>
......
......@@ -32,15 +32,16 @@ def _hx_country_level_authorships(request, country):
"cumulative": {
"publications_count": publications.count(),
"authorships_count": authorships.count(),
"authors_count": authorships.values_list("profile").distinct().count(),
},
"per_year": {}
}
for year in pubyears:
authorships_year = authorships.filter(publication__publication_date__year=year)
context["per_year"][year] = {
"publications_count": publications.filter(publication_date__year=year).count(),
"authorships_count": authorships.filter(
publication__publication_date__year=year
).count(),
"authorships_count": authorships_year.count(),
"authors_count": authorships_year.values_list("profile").distinct().count(),
}
return render(request, "stats/_hx_country_level_authorships.html", context)
......
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