diff --git a/journals/models.py b/journals/models.py index b3736a50eb421a44aef2ad6462cf167d70c11ee4..c27612810d466803c7e48b4b532c86519921d5c7 100644 --- a/journals/models.py +++ b/journals/models.py @@ -158,6 +158,23 @@ class Journal(models.Model): deltat += (pub.latest_citedby_update.date() - pub.publication_date).days return (ncites * 365.25/deltat) + def citedby_impact_factor(self, year): + """ + Computes the impact factor for a given year YYYY, from Crossref cited-by data. + This is defined as the total number of citations in year YYYY + for all papers published in years YYYY-1 and YYYY-2, divided + by the number of papers published in year YYYY. + """ + publications = self.get_publications().filter( + models.Q(publication_date__year=year-1) | models.Q(publication_date__year=year-2)) + nrpub = publications.count() + if nrpub == 0: + return 0 + ncites = 0 + for pub in publications: + if pub.citedby and pub.latest_citedby_update: + ncites += len(pub.citedby) + return ncites/nrpub class Volume(models.Model): """ diff --git a/stats/templates/stats/statistics.html b/stats/templates/stats/statistics.html index 1e45058b4448e4f2183dc84bdc1f4fa20441ba0a..a144617d177cf98d9c64d646452077e439ec6dbc 100644 --- a/stats/templates/stats/statistics.html +++ b/stats/templates/stats/statistics.html @@ -42,6 +42,9 @@ {% if journal %} <h2>Results:</h2> + {% if year %} + <h3>Impact factor (Cited-by) for {{ year }}: {{ citedby_impact_factor }}</h3> + {% endif %} <table class="table"> <tr> <th>DOI label</th> diff --git a/stats/views.py b/stats/views.py index 4e2de0c8bf8c25b5c33e42aaba3da753577a1d16..1d79d329cb3af2b82dd410468b3d5b6d354e3e88 100644 --- a/stats/views.py +++ b/stats/views.py @@ -22,6 +22,7 @@ def statistics(request, journal_doi_label=None, volume_nr=None, issue_nr=None, y context['journal'] = journal if year: context['year'] = year + context['citedby_impact_factor'] = journal.citedby_impact_factor(year) submissions = Submission.objects.filter( submitted_to_journal=journal_doi_label).originally_submitted( datetime.date(int(year), 1, 1), datetime.date(int(year), 12, 31))