Analytics

_images/survey-benchmarks.svg

The core of algorithm to select and aggregate answers based on questions, accounts and dates is implemented in:

BenchmarkMixin.get_questions_by_key(prefix=None, initial=None)

Returns a dictionnary of questions indexed by pk populated with aggregated benchmarks.

Overriding get_accounts is the main customization point of the algorithm. All benchmarks API views (see Guide to Benchmarks API) are implemented by deriving from BenchmarkAPIView combined with one of the following mixins:

BenchmarkMixin.get_accounts()

Returns all accounts in the database, and as such prevent display of individual answers. accounts_start_at and accounts_ends_at have no effect.

AccessiblesAccountsMixin.get_accounts()

Returns accounts accessible by a profile in a specific date range specified by accounts_start_at and accounts_ends_at.

EngagedAccountsMixin.get_accounts()

Returns accounts engaged by a profile in a specific date range specified by accounts_start_at and accounts_ends_at.

EditableFilterAccountsMixin.get_accounts()

Returns accounts either part of a nominative set of accounts, or which have provided a specific answer to a question within the period accounts_start_at and accounts_ends_at.

Aggregates and answers (when nomminative profiles are shown) are retrieved through survey.queries.sql_benchmarks_counts and survey.queries.sql_benchmarks_samples respectively.