function statistics_ranking

You are here

7 statistics.module statistics_ranking()
8 statistics.module statistics_ranking()

Implements hook_ranking().

File

core/modules/statistics/statistics.module, line 208
Logs and displays content statistics for a site.

Code

function statistics_ranking() {
  if (\Drupal::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. Note that the CAST here is necessary for PostgreSQL, 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 * (CAST (:statistics_scale AS DECIMAL(10,4))))',
        'arguments' => array(':statistics_scale' => \Drupal::state()->get('statistics.node_counter_scale') ? : 0),
      ),
    );
  }
}