function statistics_ranking
Same name in other branches
- 7.x modules/statistics/statistics.module \statistics_ranking()
- 9 core/modules/statistics/statistics.module \statistics_ranking()
- 8.9.x core/modules/statistics/statistics.module \statistics_ranking()
- 10 core/modules/statistics/statistics.module \statistics_ranking()
Implements hook_ranking().
File
-
core/
modules/ statistics/ statistics.module, line 93
Code
function statistics_ranking() {
if (\Drupal::config('statistics.settings')->get('count_content_views')) {
return [
'views' => [
'title' => t('Number of views'),
'join' => [
'type' => 'LEFT',
'table' => 'node_counter',
'alias' => 'node_counter',
'on' => 'node_counter.nid = i.sid',
],
// Inverse law that maps the highest view count on the site to 1 and 0
// to 0. Note that the ROUND here is necessary for PostgreSQL and SQLite
// in order to ensure that the :statistics_scale argument is treated as
// a numeric type, because the PostgreSQL PDO driver sometimes puts
// values in as strings instead of numbers in complex expressions like
// this.
'score' => '2.0 - 2.0 / (1.0 + node_counter.totalcount * (ROUND(:statistics_scale, 4)))',
'arguments' => [
':statistics_scale' => \Drupal::state()->get('statistics.node_counter_scale', 0),
],
],
];
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.