Commit 6e334892 authored by Dries's avatar Dries

- Patch #440768 by Dave Reid: move {node_counter} table from node module to statistics module.

parent e99838fb
......@@ -174,42 +174,6 @@ function node_schema() {
'primary key' => array('nid', 'gid', 'realm'),
);
$schema['node_counter'] = array(
'description' => 'Access statistics for {node}s.',
'fields' => array(
'nid' => array(
'description' => 'The {node}.nid for these statistics.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'totalcount' => array(
'description' => 'The total number of times the {node} has been viewed.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'size' => 'big',
),
'daycount' => array(
'description' => 'The total number of times the {node} has been viewed today.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'size' => 'medium',
),
'timestamp' => array(
'description' => 'The most recent time the {node} has been viewed.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array('nid'),
);
$schema['node_revision'] = array(
'description' => 'Stores information about each saved version of a {node}.',
'fields' => array(
......@@ -382,7 +346,8 @@ function node_schema() {
}
/**
* Drupal 6.x to 7.x updates
* @defgroup updates-6.x-to-7.x System updates from 6.x to 7.x
* @{
*/
/**
......@@ -417,5 +382,17 @@ function node_update_7002() {
}
/**
* End of 6.x to 7.x updates
* Remove the node_counter if the statistics module is uninstalled.
*/
function node_update_7003() {
$ret = array();
if (!drupal_get_installed_schema_version('statistics')) {
db_drop_table($ret, 'node_counter');
}
return $ret;
}
/**
* @} End of "defgroup updates-6.x-to-7.x"
* The next series of updates should start at 8000.
*/
......@@ -2086,8 +2086,6 @@ function node_page_view($node) {
function node_update_index() {
$limit = (int)variable_get('search_cron_limit', 100);
variable_set('node_cron_views_scale', 1.0 / max(1, db_result(db_query('SELECT MAX(totalcount) FROM {node_counter}'))));
$result = db_query_range("SELECT n.nid FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, n.nid ASC", 0, $limit);
while ($node = db_fetch_object($result)) {
......
......@@ -9,25 +9,6 @@ function statistics_install() {
drupal_install_schema('statistics');
}
/**
* Changes session ID field to VARCHAR(64) to add support for SHA-1 hashes.
*/
function statistics_update_1000() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {accesslog} CHANGE COLUMN sid sid varchar(64) NOT NULL default ''");
break;
case 'pgsql':
db_change_column($ret, 'accesslog', 'sid', 'sid', 'varchar(64)', array('not null' => TRUE, 'default' => "''"));
break;
}
return $ret;
}
/**
* Implementation of hook_uninstall().
*/
......@@ -35,6 +16,7 @@ function statistics_uninstall() {
// Remove tables.
drupal_uninstall_schema('statistics');
// Remove variables.
variable_del('statistics_count_content_views');
variable_del('statistics_enable_access_log');
variable_del('statistics_flush_accesslog_timer');
......@@ -115,9 +97,50 @@ function statistics_schema() {
'primary key' => array('aid'),
);
$schema['node_counter'] = array(
'description' => 'Access statistics for {node}s.',
'fields' => array(
'nid' => array(
'description' => 'The {node}.nid for these statistics.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'totalcount' => array(
'description' => 'The total number of times the {node} has been viewed.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'size' => 'big',
),
'daycount' => array(
'description' => 'The total number of times the {node} has been viewed today.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'size' => 'medium',
),
'timestamp' => array(
'description' => 'The most recent time the {node} has been viewed.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array('nid'),
);
return $schema;
}
/**
* @defgroup updates-6.x-to-7.x System updates from 6.x to 7.x
* @{
*/
/**
* Allow longer referrers.
*/
......@@ -126,3 +149,8 @@ function statistics_update_7000() {
db_change_field($ret, 'accesslog', 'url', 'url', array('type' => 'text', 'not null' => FALSE));
return $ret;
}
/**
* @} End of "defgroup updates-6.x-to-7.x"
* The next series of updates should start at 8000.
*/
......@@ -388,3 +388,10 @@ function statistics_ranking() {
);
}
}
/**
* Implementation of hook_update_index().
*/
function statistics_update_index() {
variable_set('node_cron_views_scale', 1.0 / max(1, db_result(db_query('SELECT MAX(totalcount) FROM {node_counter}'))));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment