diff og_statistics.install @ 2:48f07e7acaca

OG Stats 1.0-rc2
author Franck Deroche <franck@defr.org>
date Tue, 24 Nov 2009 14:27:37 +0100
parents 9ce879ecbce6
children
line wrap: on
line diff
--- a/og_statistics.install	Tue Nov 24 14:25:13 2009 +0100
+++ b/og_statistics.install	Tue Nov 24 14:27:37 2009 +0100
@@ -1,5 +1,5 @@
 <?php
-// $Id: og_statistics.install,v 1.2 2009/05/29 16:46:25 dereine Exp $
+// $Id: og_statistics.install,v 1.2.2.1 2009/08/12 19:53:28 dereine Exp $
 
 /**
  * @file
@@ -65,6 +65,48 @@
         'not null'        => FALSE,
         'default'         => 0,
       ),
+      'last_comment_uid' => array(
+        'description' => 'Last {users}.uid to post a comment in a group.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => FALSE,
+        'default' => 0,
+      ),
+      'last_comment_nid' => array(
+        'description' => 'Node the last comment was posted to in a group.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => FALSE,
+        'default' => 0,
+      ),
+      'last_comment_cid' => array(
+        'description' => '{comments}.cid of the last comment in a group.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => FALSE,
+        'default' => 0,
+      ),
+      'last_node_nid' => array(
+        'description' => 'Last {node}.nid posted to a group.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => FALSE,
+        'default' => 0,
+      ),
+      'last_node_uid' => array(
+        'description' => '{users}.uid of the last node posted to a group.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => FALSE,
+        'default' => 0,
+      ),
+      'last_member_uid' => array(
+        'description' => '{users}.uid of the last user to join a group.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => FALSE,
+        'default' => 0,
+      ),
     ),
     'primary key' => array('nid'),
   );
@@ -78,3 +120,32 @@
 function og_statistics_uninstall() {
   drupal_uninstall_schema('og_statistics');
 }
+
+/**
+ * Adds more verbose og statistics.
+ */
+function og_statistics_update_6001() {
+  $ret = array();
+  $schema = drupal_get_schema_unprocessed('og_statistics');
+  $table_definition = $schema['og_statistics'];
+  // Add detailed columns for last comment post.
+  foreach (array('last_comment_uid', 'last_comment_nid', 'last_comment_cid') as $column) {
+    if (!db_column_exists('og_statistics', $column)) {
+      db_add_field($ret, 'og_statistics', $column, $table_definition['fields'][$column]);
+    }
+  }
+  // Add detailed columns for last node post.
+  foreach (array('last_node_uid', 'last_node_nid') as $column) {
+    if (!db_column_exists('og_statistics', $column)) {
+      db_add_field($ret, 'og_statistics', $column, $table_definition['fields'][$column]);
+    }
+  }
+  // Add detailed columns for last user to join.
+  foreach (array('last_member_uid') as $column) {
+    if (!db_column_exists('og_statistics', $column)) {
+      db_add_field($ret, 'og_statistics', $column, $table_definition['fields'][$column]);
+    }
+  }
+  // Rebuild schema.
+  drupal_get_schema('og_statistics', TRUE);
+}
\ No newline at end of file