summaryrefslogtreecommitdiff
path: root/plugins/Sitemap/SitemapPlugin.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-05-03 14:00:12 -0400
committerEvan Prodromou <evan@status.net>2010-06-01 13:52:28 -0700
commit7d85b79814e7e91a88f23d7c7e752a0bcfc83ff4 (patch)
tree924922af98267b04f243797dbf6fbbde7664f44a /plugins/Sitemap/SitemapPlugin.php
parent3e349a71cad00f2f99ecccb73dce3805b4fcb41c (diff)
Database tables to cache expensive query data
We need to bundle counts of notices and users by date. This can be expensive for large sites. So, new tables are added to cache the results of these queries, which don't change after the date is over.
Diffstat (limited to 'plugins/Sitemap/SitemapPlugin.php')
-rw-r--r--plugins/Sitemap/SitemapPlugin.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/plugins/Sitemap/SitemapPlugin.php b/plugins/Sitemap/SitemapPlugin.php
index 6fc702104..831694efc 100644
--- a/plugins/Sitemap/SitemapPlugin.php
+++ b/plugins/Sitemap/SitemapPlugin.php
@@ -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;
+ }
}