summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
authorCiaranG <ciaran@ciarang.com>2008-09-11 15:23:48 -0400
committerCiaranG <ciaran@ciarang.com>2008-09-11 15:23:48 -0400
commitb13233fed40ee132779906cfa29e00f8c28631df (patch)
treeb5b0730c9392f7101198650831b956c7aa832934 /actions
parentce2eaf84aac790a647cda202d6e361ffb1fdff3b (diff)
PostgreSQL: Make tag cloud query work - also fixes what is surely an ignored error in the mysql query
darcs-hash:20080911192348-f6e2c-b846b777b382386de56ca01d957dc5e55161fced.gz
Diffstat (limited to 'actions')
-rw-r--r--actions/tag.php15
1 files changed, 14 insertions, 1 deletions
diff --git a/actions/tag.php b/actions/tag.php
index 1042513d5..52d91d724 100644
--- a/actions/tag.php
+++ b/actions/tag.php
@@ -88,8 +88,21 @@ class TagAction extends StreamAction {
{
# This should probably be cached rather than recalculated
$tags = DB_DataObject::factory('Notice_tag');
+
+ #Need to clear the selection and then only re-add the field
+ #we are grouping by, otherwise it's not a valid 'group by'
+ #even though MySQL seems to let it slide...
+ $tags->selectAdd();
+ $tags->selectAdd('tag');
+
+ #Add the aggregated columns...
$tags->selectAdd('max(notice_id) as last_notice_id');
- $tags->selectAdd(sprintf('sum(exp(-(now() - created)/%f)) as weight', common_config('tag', 'dropoff')));
+ if(common_config('db','type')=='pgsql') {
+ $calc='sum(exp(-extract(epoch from (now()-created))/%f)) as weight';
+ } else {
+ $calc='sum(exp(-(now() - created)/%f)) as weight';
+ }
+ $tags->selectAdd(sprintf($calc, common_config('tag', 'dropoff')));
$tags->groupBy('tag');
$tags->orderBy('weight DESC');