function statistics_ranking

Implements hook_ranking().

File

drupal/core/modules/statistics/statistics.module, line 427
Logs and displays access statistics for a site.

Code

function statistics_ranking() {
  if (config('statistics.settings')
    ->get('count_content_views')) {
    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' => state()
            ->get('statistics.node_counter_scale') ?: 0,
        ),
      ),
    );
  }
}