diff options
author | Zach Copley <zach@controlyourself.ca> | 2009-03-04 16:21:37 -0800 |
---|---|---|
committer | Zach Copley <zach@controlyourself.ca> | 2009-03-04 16:21:37 -0800 |
commit | 77e4fad9fac63151c3eee0c3c785c8cf2fa356fb (patch) | |
tree | 9803f20b702a6233d67bd201166268f9780e5e4e /lib/popularnoticesection.php | |
parent | 36bb33fb1d7b4befe2fb68c2eef0712619359293 (diff) | |
parent | e239a5529abc0958c4f874811ff704f1e5d6ba62 (diff) |
Merge branch '0.7.x' of git@gitorious.org:laconica/dev into 0.7.x
Diffstat (limited to 'lib/popularnoticesection.php')
-rw-r--r-- | lib/popularnoticesection.php | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/popularnoticesection.php b/lib/popularnoticesection.php index c7c7f0215..f7fb93554 100644 --- a/lib/popularnoticesection.php +++ b/lib/popularnoticesection.php @@ -48,10 +48,16 @@ class PopularNoticeSection extends NoticeSection { function getNotices() { - $qry = 'SELECT notice.*, '. - 'sum(exp(-(now() - fave.modified) / %s)) as weight ' . + if (common_config('db', 'type') == 'pgsql') { + $weightexpr='sum(exp(-extract(epoch from (now() - fave.modified)) / %s))'; + } else { + $weightexpr='sum(exp(-(now() - fave.modified) / %s))'; + } + + $qry = 'SELECT notice.id, '. + $weightexpr . ' as weight ' . 'FROM notice JOIN fave ON notice.id = fave.notice_id ' . - 'GROUP BY fave.notice_id ' . + 'GROUP BY notice.id ' . 'ORDER BY weight DESC'; $offset = 0; |