diff options
author | Brion Vibber <brion@status.net> | 2010-01-04 11:55:27 -0800 |
---|---|---|
committer | Brion Vibber <brion@status.net> | 2010-01-04 11:55:27 -0800 |
commit | 6911e1c7972c3adec53d0fe04ebdd7da0fbd8b12 (patch) | |
tree | 014e47a5abc93e3c351f65922e5ef517ffcf1eef /actions/favorited.php | |
parent | e3466ab51cf68bd62ecd914a3771ed33de824e52 (diff) |
Ticket 2141: bugs with weighted popularity lists across year boundary.
Consolidated several separate implementations of the same weighting algorithm into common_sql_weight() and fixed some bugs...
For MySQL, now using timestampdiff() instead of subtraction for the comparison, so we get sane results when the year doesn't match, and utc_timestamp() rather than now() so we don't get negative ages for recent items with local server timezone.
Unknown whether the same problems affect PostgreSQL, but note that it lacks the timestampdiff() SQL function.
Diffstat (limited to 'actions/favorited.php')
-rw-r--r-- | actions/favorited.php | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/actions/favorited.php b/actions/favorited.php index 150b67b0b..9ffa5b844 100644 --- a/actions/favorited.php +++ b/actions/favorited.php @@ -185,11 +185,7 @@ class FavoritedAction extends Action function showContent() { - if (common_config('db', 'type') == 'pgsql') { - $weightexpr='sum(exp(-extract(epoch from (now() - fave.modified)) / %s))'; - } else { - $weightexpr='sum(exp(-(now() - fave.modified) / %s))'; - } + $weightexpr = common_sql_weight('fave.modified', common_config('popular', 'dropoff')); $qry = 'SELECT notice.*, '. $weightexpr . ' as weight ' . @@ -207,7 +203,7 @@ class FavoritedAction extends Action } $notice = Memcached_DataObject::cachedQuery('Notice', - sprintf($qry, common_config('popular', 'dropoff')), + $qry, 600); $nl = new NoticeList($notice, $this); |