]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Sitemap/SitemapPlugin.php
Database tables to cache expensive query data
[quix0rs-gnu-social.git] / plugins / Sitemap / SitemapPlugin.php
index 6fc7021049a5f5b0d2f94ef686c71fa8328b1429..831694efc6a0743fd618adbb3aa980f9c02aebc7 100644 (file)
@@ -121,4 +121,40 @@ class SitemapPlugin extends Plugin
                           'index' => '[1-9][0-9]*'));
         return true;
     }
+
+    /**
+     * Database schema setup
+     *
+     * We cache some data persistently to avoid overlong queries.
+     *
+     * @see Sitemap_user_count
+     * @see Sitemap_notice_count
+     *
+     * @return boolean hook value; true means continue processing, false means stop.
+     */
+
+    function onCheckSchema()
+    {
+        $schema = Schema::get();
+
+        // For storing user-submitted flags on profiles
+
+        $schema->ensureTable('sitemap_user_count',
+                             array(new ColumnDef('registration_date', 'date', null,
+                                                 true, 'PRI'),
+                                   new ColumnDef('user_count', 'integer'),
+                                   new ColumnDef('created', 'datetime',
+                                                 null, false),
+                                   new ColumnDef('modified', 'timestamp')));
+
+        $schema->ensureTable('sitemap_notice_count',
+                             array(new ColumnDef('notice_date', 'date', null,
+                                                 true, 'PRI'),
+                                   new ColumnDef('notice_count', 'integer'),
+                                   new ColumnDef('created', 'datetime',
+                                                 null, false),
+                                   new ColumnDef('modified', 'timestamp')));
+
+        return true;
+    }
 }