You are here

README.txt in Radioactivity 8.3

With the Radioactivity module you can measure popularity of your content. In
combination with Views you can makes lists of popular content.

INSTALLATION
============

Install and enable the module as usual:
https://www.drupal.org/docs/extending-drupal/installing-modules

The Radioactivity module has no dependencies other than Drupal core.

CONFIGURATION
=============

The Radioactivity field stores the energy value in the entity storage just like
for example a text field. This is the classic approach. It is technically proven but
has a known problem which prevents editors for saving the node when cron updates
the energy values while the node is being edited.
See https://www.drupal.org/project/radioactivity/issues/3106687

FIELD CONFIGURATION
===================

Each Radioactivity field has storage settings that determine how the popularity
is measured and how it behaves over time.

Energy profile
  - Count: Each visit increases the energy value by one. Never decreases.
    Use this profile to count visits.
  - Linear: Energy increases by the emission amount. Decreases the energy value
    by 1 per second.
  - Decay: Energy increases by the emission amount. Decreases the energy value
    by 50% per half-life time (see below).

Granularity
  The minimum time in seconds before energy decay will be re-calculated. Cron
  should run at least one time within this time frame. If for example you want
  the popularity list to be updated daily, the granularity should be 3600 * 24
  seconds or less. A lower Granularity spreads the load of processing decays.
  Set this time to a (very) low value to update on each cron.

Half-life time
  The time in seconds in which the energy decreases by 50%. Start with a high
  value (e.g. 1 week or longer). Create a view in the backend to monitor the
  result and monitor the behaviour over time. Decrease the half-life time to
  better distinguish between old and new. Increase the half-life time if not
  enough nodes have an energy value.

Cutoff
  Energy levels under this value is set to zero. Example: 0.5, 2.
  This value is used limit the number of entities that must be processed.
  Energy values below this threshold are considered to be not relevant for
  popularity. Start with a low value (e.g. 1/10th of a single emission) and
  increase the value to reduce the number of items. For example, you have list
  of the 10 most popular nodes. Set the cut-off value equal to the average
  energy of the item on position 20.

Default energy (field setting)
  The initial energy value when content is created. Use this value to give new
  content an initial (high) ranking in the popularity list. Start with 10 times
  the energy of a single emission (see below) and adjust the value to
  balance new and popular content within the list of popular items.

Energy (Emitter formatter)
  The amount of energy to emit when this field is displayed. Each time the
  content is displayed this value will be added to the energy level. Use a
  simple value such as 1 or 10. On a busy site use 1 on a low traffic site use
  10. If you count popularity using different view modes (e.g. Full content and
  Search result) you can use distinct Energy values to rate each view mode
  differently (e.g. Full content: 10, Search result: 1).

CRON
====

The Radioactivity module uses cron to update the energy values. Only after a
cron job you will see the energy level change. Emissions are processed (energy
increases) and decay is processed (energy decreases). Emissions are processed
on each cron job. Decay is processed after the Granularity time (see above) has
elapsed.

MULTILINGUAL
============

The Radioactivity field does not support translation, the energy values are
equal in each language. Emission and decay does not differentiate between
languages.

VIEWS INTEGRATION
=================

The energy value of the radioactivity field is available in Views and is
typically used to show a list of popular pages.

Tip: Also create a backend view that lists all content with radioactivity
field(s) and also shows the energy value. This can be used to tweek the field
configuration for optimal performance.

STORAGE
=======

Radioactivity module provides two storages to store the emitted incident data:
in the database (default) or in a file. The Default Storage uses Drupal's
key/value storage in the database. The Rest Storage uses a file in the server's
temporary file directory.

The storage configuration can currently only be altered in settings.php. If you
want to use the default storage, you can skip the section below.

```
// Use the radioactivity Default Storage (database).
$config['radioactivity.storage']['type'] = 'default';
```

```
// Use the radioactivity Rest Storage (file).
$config['radioactivity.storage']['type'] = 'rest_local';
```

The provided rest storage service uses a php executable as endpoint. The
default endpoint is: /path/to/radioactivity/endpoints/file/rest.php. If you
want to run the service under another path (e.g. directly under the root) or on
a different host, you can override the endpoint url:

```
// Use the radioactivity Rest Storage (file) on a custom endpoint.
$config['radioactivity.storage'] = [
    'type' => 'rest_remote',
    'endpoint' => 'http://www.example.com/rest.php',
];
```

NOTE! When using a different host name you may need to set CORS (Cross-origin
resource sharing) for things to work properly.

DEBUGGING
=========

When the energy value does not increase or decrease as you expect, use the
hints below to check.

- Use the Emitter formatter (/admin/structure/types/manage/{node type}/display
  and select the Display 'Energy level + emit' setting. The field will now
  display the current energy value.
- Edit the node and check the Energy value in the field. The value is the same
  as the displayed value in the previous hint.
- When a page is visited a POST request should be fired to
	/radioactivity/emit (default storage) or
 	/path/to/radioactivity/endpoints/file/rest.php (local rest storage)
- Emissions are stored in the database table (default storage)
  `SELECT * FROM `key_value` WHERE `name` = 'radioactivity_incidents';`
  or is in file at /tmp/radioactivity-payload.json (assuming the server
  temporary storage is /tmp)
- Cron reports the Radioactivity processing results. Example
  ```
  drush cron
   ...
   [notice] Processed 2 radioactivity decays.
   [notice] Processed 1 radioactivity incidents.
  ```
  The numbers refer to the number of entities processed, not the individual
  incidents. Unpublished entities also gets counted, but their data is
  not processed (no decay).
  Set the Granularity to 1 to make sure each cron job will update the energy.

File

README.txt
View source
  1. With the Radioactivity module you can measure popularity of your content. In
  2. combination with Views you can makes lists of popular content.
  3. INSTALLATION
  4. ============
  5. Install and enable the module as usual:
  6. https://www.drupal.org/docs/extending-drupal/installing-modules
  7. The Radioactivity module has no dependencies other than Drupal core.
  8. CONFIGURATION
  9. =============
  10. The Radioactivity field stores the energy value in the entity storage just like
  11. for example a text field. This is the classic approach. It is technically proven but
  12. has a known problem which prevents editors for saving the node when cron updates
  13. the energy values while the node is being edited.
  14. See https://www.drupal.org/project/radioactivity/issues/3106687
  15. FIELD CONFIGURATION
  16. ===================
  17. Each Radioactivity field has storage settings that determine how the popularity
  18. is measured and how it behaves over time.
  19. Energy profile
  20. - Count: Each visit increases the energy value by one. Never decreases.
  21. Use this profile to count visits.
  22. - Linear: Energy increases by the emission amount. Decreases the energy value
  23. by 1 per second.
  24. - Decay: Energy increases by the emission amount. Decreases the energy value
  25. by 50% per half-life time (see below).
  26. Granularity
  27. The minimum time in seconds before energy decay will be re-calculated. Cron
  28. should run at least one time within this time frame. If for example you want
  29. the popularity list to be updated daily, the granularity should be 3600 * 24
  30. seconds or less. A lower Granularity spreads the load of processing decays.
  31. Set this time to a (very) low value to update on each cron.
  32. Half-life time
  33. The time in seconds in which the energy decreases by 50%. Start with a high
  34. value (e.g. 1 week or longer). Create a view in the backend to monitor the
  35. result and monitor the behaviour over time. Decrease the half-life time to
  36. better distinguish between old and new. Increase the half-life time if not
  37. enough nodes have an energy value.
  38. Cutoff
  39. Energy levels under this value is set to zero. Example: 0.5, 2.
  40. This value is used limit the number of entities that must be processed.
  41. Energy values below this threshold are considered to be not relevant for
  42. popularity. Start with a low value (e.g. 1/10th of a single emission) and
  43. increase the value to reduce the number of items. For example, you have list
  44. of the 10 most popular nodes. Set the cut-off value equal to the average
  45. energy of the item on position 20.
  46. Default energy (field setting)
  47. The initial energy value when content is created. Use this value to give new
  48. content an initial (high) ranking in the popularity list. Start with 10 times
  49. the energy of a single emission (see below) and adjust the value to
  50. balance new and popular content within the list of popular items.
  51. Energy (Emitter formatter)
  52. The amount of energy to emit when this field is displayed. Each time the
  53. content is displayed this value will be added to the energy level. Use a
  54. simple value such as 1 or 10. On a busy site use 1 on a low traffic site use
  55. 10. If you count popularity using different view modes (e.g. Full content and
  56. Search result) you can use distinct Energy values to rate each view mode
  57. differently (e.g. Full content: 10, Search result: 1).
  58. CRON
  59. ====
  60. The Radioactivity module uses cron to update the energy values. Only after a
  61. cron job you will see the energy level change. Emissions are processed (energy
  62. increases) and decay is processed (energy decreases). Emissions are processed
  63. on each cron job. Decay is processed after the Granularity time (see above) has
  64. elapsed.
  65. MULTILINGUAL
  66. ============
  67. The Radioactivity field does not support translation, the energy values are
  68. equal in each language. Emission and decay does not differentiate between
  69. languages.
  70. VIEWS INTEGRATION
  71. =================
  72. The energy value of the radioactivity field is available in Views and is
  73. typically used to show a list of popular pages.
  74. Tip: Also create a backend view that lists all content with radioactivity
  75. field(s) and also shows the energy value. This can be used to tweek the field
  76. configuration for optimal performance.
  77. STORAGE
  78. =======
  79. Radioactivity module provides two storages to store the emitted incident data:
  80. in the database (default) or in a file. The Default Storage uses Drupal's
  81. key/value storage in the database. The Rest Storage uses a file in the server's
  82. temporary file directory.
  83. The storage configuration can currently only be altered in settings.php. If you
  84. want to use the default storage, you can skip the section below.
  85. ```
  86. // Use the radioactivity Default Storage (database).
  87. $config['radioactivity.storage']['type'] = 'default';
  88. ```
  89. ```
  90. // Use the radioactivity Rest Storage (file).
  91. $config['radioactivity.storage']['type'] = 'rest_local';
  92. ```
  93. The provided rest storage service uses a php executable as endpoint. The
  94. default endpoint is: /path/to/radioactivity/endpoints/file/rest.php. If you
  95. want to run the service under another path (e.g. directly under the root) or on
  96. a different host, you can override the endpoint url:
  97. ```
  98. // Use the radioactivity Rest Storage (file) on a custom endpoint.
  99. $config['radioactivity.storage'] = [
  100. 'type' => 'rest_remote',
  101. 'endpoint' => 'http://www.example.com/rest.php',
  102. ];
  103. ```
  104. NOTE! When using a different host name you may need to set CORS (Cross-origin
  105. resource sharing) for things to work properly.
  106. DEBUGGING
  107. =========
  108. When the energy value does not increase or decrease as you expect, use the
  109. hints below to check.
  110. - Use the Emitter formatter (/admin/structure/types/manage/{node type}/display
  111. and select the Display 'Energy level + emit' setting. The field will now
  112. display the current energy value.
  113. - Edit the node and check the Energy value in the field. The value is the same
  114. as the displayed value in the previous hint.
  115. - When a page is visited a POST request should be fired to
  116. /radioactivity/emit (default storage) or
  117. /path/to/radioactivity/endpoints/file/rest.php (local rest storage)
  118. - Emissions are stored in the database table (default storage)
  119. `SELECT * FROM `key_value` WHERE `name` = 'radioactivity_incidents';`
  120. or is in file at /tmp/radioactivity-payload.json (assuming the server
  121. temporary storage is /tmp)
  122. - Cron reports the Radioactivity processing results. Example
  123. ```
  124. drush cron
  125. ...
  126. [notice] Processed 2 radioactivity decays.
  127. [notice] Processed 1 radioactivity incidents.
  128. ```
  129. The numbers refer to the number of entities processed, not the individual
  130. incidents. Unpublished entities also gets counted, but their data is
  131. not processed (no decay).
  132. Set the Granularity to 1 to make sure each cron job will update the energy.