diff --git a/scipost_django/api/viewsets/base.py b/scipost_django/api/viewsets/base.py index ffaf219ef5e6a9622a1bbfa07f5410b13e12b57e..a42fba51153ea06e8af993e2e0538222ca0cd778 100644 --- a/scipost_django/api/viewsets/base.py +++ b/scipost_django/api/viewsets/base.py @@ -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() diff --git a/scipost_django/journals/api/filtersets/publication.py b/scipost_django/journals/api/filtersets/publication.py index 4fe8d3f38caa8a6056c7a0f53e34073bf66989d4..1384dedbd76454cd8bb5d8a8095af9eb5bdf17af 100644 --- a/scipost_django/journals/api/filtersets/publication.py +++ b/scipost_django/journals/api/filtersets/publication.py @@ -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", + ], } diff --git a/scipost_django/stats/templates/stats/_hx_country_level_authorships.html b/scipost_django/stats/templates/stats/_hx_country_level_authorships.html index a47db94a6c2ee3b8a928874f99eeea48d9f1ab0a..12db4a7c5aa768bbf2bf070ecbe4015f006a297c 100644 --- a/scipost_django/stats/templates/stats/_hx_country_level_authorships.html +++ b/scipost_django/stats/templates/stats/_hx_country_level_authorships.html @@ -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> diff --git a/scipost_django/stats/views.py b/scipost_django/stats/views.py index ab7154567ebde26d60886028579f868b0cbe9ac3..fd8ba2c185dcbaba174bdbd92d776d5f75cda469 100644 --- a/scipost_django/stats/views.py +++ b/scipost_django/stats/views.py @@ -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)