Smarty

  1. Home
  2. Docs
  3. Smarty
  4. Smarty configuration and maintenance
  5. Setting up television viewing statistics and subscriber dynamics

Setting up television viewing statistics and subscriber dynamics

Television viewing statistics

First of all, you need to raise the MongoDB server, which will store the data of the subscribers’ TV viewing. The minimum supported version of MongoDB is 3.4.

Next, section INSTALLED_APPS smarty configuration file needs to add a module viewstats, as well as specify the data to connect to the raised MongoDB server:
MONGODB_HOST - MongoDB server address, data type strap;
MONGODB_PORT - MongoDB server port, data type int;
MONGODB_NAME - Name of database, type of data strap;
MONGODB_USERNAME - User name for authorization, data type strap;
MONGODB_PASSWORD - Password for authorization, data type strap;
MONGODB_AUTH_METHOD - Authorization method (depending on MongoDB version), data type strap;

And identify any missing migration team:

smarty_manage migrate --settings=settings.smarty

Example configuration:

INSTALLED_APPS +=
'viewstats',
///...
)

MONGODB_HOST = '127.0.0.1'
MONGODB_PORT = 27017
MONGODB_NAME = 'Test'
MONGODB_USERNAME = 'Test'
MONGODB_PASSWORD = 'Password'
MONGODB_AUTH_METHOD = 'SCRAM-SHA-1'

In order for subscriber devices to start sending statistics to the server, it is necessary to enable its sending in the administration panel on the “STB and Application Settings” page (checkbox “Enable statistical data collection to the Smarty server”).

Creating smart channel sorting

smarty_manage create_channel_sorting_by_popularity --settings=settings.

When executing this command, a sorting of channels is created based on television viewing statistics, based on the specified parameters in the team.

The necessary parameters to execute this command:

-client_id - a list of customer identifiers, through a comma, for which caching is necessary;

-days_number the number of days during which television viewing should be considered;

- criterion Characteristics by which to evaluate popularity. Possible values:
watch - the total viewing time of the channel;
watch_sessions by the number of channel inclusions;
average the average viewing time of the channel;
median_watch_time the median viewing time of the channel.

Additional parameters of the team:
-devices - a list of devices for which you should take into account the statistics of tv viewing (system names of devices are transmitted, by default - all);
-tariffs - a list of tariffs for which it is worth taking into account the statistics of tv viewing (tariff identifiers are transmitted, by default - all);
--accounts_active only take into account statistics from active accounts.

Creating a selection of popular TV channels

smarty_manage create_channel_selection_by_popularity --settings=settings;

Parameters:
-client_id This option is mandatory and determines the Client identifier for which the selection will be created.
-days_number this parameter is mandatory and determines the number of days during which you should take into account television viewing.
- criterion This parameter is mandatory and determines the characteristic on which the selection will be created. Possible values: watch (total channel viewing time), watch_sessions (number of channel viewing sessions), average (average channel viewing time), median_watch_time (median viewing time).
-devices parameter for creating a collection for certain devices (by default, the collection is created for all devices).
--accounts_active The parameter allows you to create a selection only based on active accounts. Possible values: true, false. By default falsely.
-tariffs selection of certain tariffs to create a collection (all tariffs are taken into account by default).
--selection_size The parameter determines the size of the set created. In the absence of information about a sufficient number of channels, channels without statistics are added to the desired number. By default 17.

Example of using a command:

Creating for Client=1 a selection of weekly popular channels by viewing time:

smarty_manage create_channel_selection_by_popularity --client_id=1 --days_number=7 --criterion=watch_time --settings=settings;

Creating a selection of popular television programs

smarty_manage create_epg_selection_by_popularity --settings=settings.

Parameters:
-client_id This option is mandatory and determines the Client identifier for which the selection will be created.
-days_number this parameter is mandatory and determines the number of days during which information on transfers is collected.
-devices parameter for creating a collection for certain devices (by default, the collection is created for all devices).
-tariffs selection of certain tariffs to create a collection (all tariffs are taken into account by default).
--selection_size The parameter determines the size of the set created. In the absence of information on a sufficient number of transmissions, transmissions without statistics are added to the desired number. By default 17.
-categories - parameter for creating a selection of certain categories of channels (all categories are taken into account by default), id categories can be seen in the section Content Settings - TV Categories.
-channels only those channels whose id is specified in this parameter are considered.
--election_name - the name of the collection. If not specified, the selection will be called "Days_number ($selection_size)".

Example of using a command:

Create a selection of 27 popular programs for Client=1 in 30 days with categories "Children" (id=2) and "Educational" (id=7):

smarty_manage create_epg_selection_by_popularity --selection_name="Children's cognitive" --client_id=1 --days_number=30 --selection_size=27 --categories=2 --categories=7 --settings=settings;

Dynamics of subscribers

First of all, you need to raise the MongoDB server, which will store the data of the subscribers’ TV viewing. The minimum supported version of MongoDB is 3.4.

Configuring the module for collecting statistics by subscribers

To display information inside the tab "Dynamics of subscribers" in the section INSTALLED_APPS in a configuration file other than a module viewstats add a module smartystats .

After adding modules, all missing migrations must be installed by the team

smarty_manage migrate --settings=settings.smarty

And set up the correct work of management teams cache_max_online and save_stats.

Team cache_max_online responsible for updating the maximum number of online subscribers for statistics. You can run with any regularity, but at least once a day.

Team save_stats it is responsible for collecting and storing statistics for each client for widgets on the subscriber dynamics screen. You can run with any regularity, but at least once a day.

To work with a large amount of data, it is recommended to configure asynchronous task execution through RQ.
More information about asynchronous tasks can be found in the section “Scaling and Resilience” – “Configuring asynchronous task execution through RQ (Redis Queue)”.

Additional teams to collect statistics

Collection of additional statistics for the report on the number of users

smarty_manage collect_daily_stats --settings=settings.

This team collects information that is used in the payment reports, as well as in the charts “Payments today” and “Subscribers who received payment” (and parts of other statistics) of the “Subscriber Dynamics” screen. The command must be executed every day at the beginning of the day (record time is saved in UTC+0).

Data caching for subscriber dynamics graphs

smarty_manage cache_customers_dynamic --settings=settings.

The team is recommended to run once an hour. For small bases, the charts will work quickly and correctly and without a given command. At the first run, the command can be executed for a long time (depending on the number of accounts, transactions and tariffs) due to the fact that the data for the entire previous month will be calculated. When restarting, data will only be calculated for the last day or hour (the data is not cached again).

Additional parameters of the team:

-client_id - a list of customer identifiers, through a comma, for which caching is necessary. If nothing is transferred to the argument, then the data is cached for all customers.