function statistics_ranking

Same name in other branches
  1. 9 core/modules/statistics/statistics.module \statistics_ranking()
  2. 8.9.x core/modules/statistics/statistics.module \statistics_ranking()
  3. 10 core/modules/statistics/statistics.module \statistics_ranking()
  4. 11.x core/modules/statistics/statistics.module \statistics_ranking()

Implements hook_ranking().

File

modules/statistics/statistics.module, line 438

Code

function statistics_ranking() {
    if (variable_get('statistics_count_content_views', 0)) {
        return array(
            'views' => array(
                'title' => t('Number of views'),
                'join' => array(
                    '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.
'score' => '2.0 - 2.0 / (1.0 + node_counter.totalcount * CAST(:scale AS DECIMAL))',
                'arguments' => array(
                    ':scale' => variable_get('node_cron_views_scale', 0),
                ),
            ),
        );
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.