statistics.models module

This module defines the AccessStatistics model. It stores statistics about the accessiblity status of papers related to any model (currently Researcher, Journal, Publisher, Department, Institution and PaperWorld).

As all these modules are spread in different apps and link to AccessStatistics, this model has been separated from the rest for dependency reasons.

The different states a paper can have are defined in COMBINED_STATUS_CHOICES (where a human-readable description is given), STATUS_QUERYSET_FILTER (where the corresponding QuerySet filters are defined) and in combined_status_for_instance() which computes the status of a particular paper.

class statistics.models.AccessStatistics(*args, **kwargs)[source]

Bases: django.db.models.base.Model, statistics.models.BareAccessStatistics

Caches numbers of papers in different access statuses for some queryset

Parameters:
  • id (AutoField) – Id
  • num_oa (IntegerField) – Num oa
  • num_ok (IntegerField) – Num ok
  • num_couldbe (IntegerField) – Num couldbe
  • num_unk (IntegerField) – Num unk
  • num_closed (IntegerField) – Num closed
  • num_tot (IntegerField) – Num tot
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception AccessStatistics.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

AccessStatistics.department_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

AccessStatistics.id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

AccessStatistics.institution_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

AccessStatistics.journal_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

AccessStatistics.num_closed

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

AccessStatistics.num_couldbe

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

AccessStatistics.num_oa

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

AccessStatistics.num_ok

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

AccessStatistics.num_tot

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

AccessStatistics.num_unk

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

AccessStatistics.objects = <django.db.models.manager.Manager object>
AccessStatistics.paperworld_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

AccessStatistics.publisher_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

AccessStatistics.researcher_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

AccessStatistics.update(queryset)[source]

Updates the statistics for papers contained in the given Paper queryset

classmethod AccessStatistics.update_all_stats(_class)[source]

Update all statistics for the objects of a given class. This calls the underlying update_stats() function for each instance of the model.

AccessStatistics.update_from_search_queryset(queryset)[source]

Updates the stats using the search index

class statistics.models.BareAccessStatistics[source]

Bases: object

A bare summary of the status of a set of publications

add(other)[source]

Adds the stats of other to self (sum of access statistics)

check_values()[source]

Checks that values are consistent (non-negative and summing up to the total).

clear()[source]

Sets all counters to zero

classmethod from_dict(d)[source]
classmethod from_queryset(qs)[source]

This method fetches all the queryset.

Parameters:qs – a queryset of Paper objects
Returns:an object of the current class, with the status of all papers in this queryset.
classmethod from_search_queryset(qs)[source]
classmethod new()[source]

Creates an empty object (all counters set to 0)

num_available

Total number of available items (from publisher or author)

num_unavailable

Total number of unavailable items

percentage_available

Percentage of available items

percentage_unavailable

Percentage of unavailable items

percentages

A dictionary whose keys are the identifiers for the paper states and whose values are the percentages of these states for the given statistics.

pie_data()[source]

Returns a dictionary containing the data needed to display the statistics as a pie.

statistics.models.COMBINED_STATUS_CHOICES = [(u'oa', <django.utils.functional.__proxy__ object>), (u'ok', <django.utils.functional.__proxy__ object>), (u'couldbe', <django.utils.functional.__proxy__ object>), (u'unk', <django.utils.functional.__proxy__ object>), (u'closed', <django.utils.functional.__proxy__ object>)]

Paper status (combined because it takes into account both the publisher policy and the full text availability).

If these states are changed, then the filters STATUS_QUERYSET_FILTER have to be updated, as well as combined_status_for_instance().

statistics.models.PDF_STATUS_CHOICES = [(u'OK', <django.utils.functional.__proxy__ object>), (u'NOK', <django.utils.functional.__proxy__ object>)]

Availability status choices

statistics.models.STATUS_CHOICES_HELPTEXT = {u'unk': <django.utils.functional.__proxy__ object>, u'ok': <django.utils.functional.__proxy__ object>, u'closed': <django.utils.functional.__proxy__ object>, u'oa': <django.utils.functional.__proxy__ object>, u'couldbe': <django.utils.functional.__proxy__ object>}

Helptext displayed when a paper logo is hovered

statistics.models.STATUS_QUERYSET_FILTER = {u'unk': <function <lambda>>, u'ok': <function <lambda>>, u'closed': <function <lambda>>, u'oa': <function <lambda>>, u'couldbe': <function <lambda>>}

Filters associated to each combined status choice These filters, once applied to a queryset of Papers, select the papers in the given state.

statistics.models.combined_status_for_instance(paper)[source]

Computes the current combined status of a given paper. This is defined here so that the function can be easily updated when we change STATUS_QUERYSET_FILTER or COMBINED_STATUS_CHOICES.