diff options
author | Evan Prodromou <evan@controlyourself.ca> | 2009-03-04 11:05:58 -0800 |
---|---|---|
committer | Evan Prodromou <evan@controlyourself.ca> | 2009-03-04 11:05:58 -0800 |
commit | 8cc19b90eeb7920b2cfe79959038c5e25f40930a (patch) | |
tree | 8608ad304d57f7395ae4bf7b58ed4be7eaa0b6a1 /lib/popularnoticesection.php | |
parent | cf4e1872ab8109ea6a3230e43cc70899a17dd075 (diff) | |
parent | a7efd4ff556bbf6bafcfc81db758ab192b8802ad (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; |