]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/grouptagcloudsection.php
PostgreSQL - made all 'weight' calculating SQL expressions compatible with both datab...
[quix0rs-gnu-social.git] / lib / grouptagcloudsection.php
index f05be85cbbdf33f49997fb663c217f3de6e2b117..5d68af28bf7bdc62e8a9ba3b3892a3b03c6d8084 100644 (file)
@@ -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 ' .