summaryrefslogtreecommitdiff
path: root/lib/grouptagcloudsection.php
diff options
context:
space:
mode:
authorCiaranG <ciaran@ciarang.com>2009-03-04 15:32:26 +0000
committerCiaranG <ciaran@ciarang.com>2009-03-04 15:32:26 +0000
commit115519a5e7e84e57656c653918efb39ab4107fe9 (patch)
tree2c66758d4df65f8d9b76cc17a6893c662debdf16 /lib/grouptagcloudsection.php
parentc02a2f189139bd3588b04e557239e243805aaeac (diff)
PostgreSQL - made all 'weight' calculating SQL expressions compatible with both databases, and made some GROUP BY queries more explicit about the fields they are selecting, for the same reason.
Diffstat (limited to 'lib/grouptagcloudsection.php')
-rw-r--r--lib/grouptagcloudsection.php8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/grouptagcloudsection.php b/lib/grouptagcloudsection.php
index f05be85cb..5d68af28b 100644
--- a/lib/grouptagcloudsection.php
+++ b/lib/grouptagcloudsection.php
@@ -58,8 +58,14 @@ class GroupTagCloudSection extends TagCloudSection
function getTags()
{
+ if (common_config('db', 'type') == 'pgsql') {
+ $weightexpr='sum(exp(-extract(epoch from (now() - notice_tag.created)) / %s))';
+ } else {
+ $weightexpr='sum(exp(-(now() - notice_tag.created) / %s))';
+ }
+
$qry = 'SELECT notice_tag.tag, '.
- 'sum(exp(-(now() - notice_tag.created)/%s)) as weight ' .
+ $weightexpr . ' as weight ' .
'FROM notice_tag JOIN notice ' .
'ON notice_tag.notice_id = notice.id ' .
'JOIN group_inbox on group_inbox.notice_id = notice.id ' .