From b80151275a8659e241b66e8f8454541d236f2f0e Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 17 Dec 2010 15:25:19 -0800 Subject: [PATCH] Update sorting on api/statuses/retweets_of_me; was and remains poorly indexed, but will use updated sorting method. --- classes/User.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/classes/User.php b/classes/User.php index 1b1b971ec7..edbd6bb2e3 100644 --- a/classes/User.php +++ b/classes/User.php @@ -800,17 +800,17 @@ class User extends Memcached_DataObject 'FROM notice original JOIN notice rept ON original.id = rept.repeat_of ' . 'WHERE original.profile_id = ' . $this->id . ' '; - if ($since_id != 0) { - $qry .= 'AND original.id > ' . $since_id . ' '; + $since = Notice::whereSinceId($since_id, 'original.id', 'original.created'); + if ($since) { + $qry .= "AND ($since) "; } - if ($max_id != 0) { - $qry .= 'AND original.id <= ' . $max_id . ' '; + $max = Notice::whereMaxId($max_id, 'original.id', 'original.created'); + if ($max) { + $qry .= "AND ($max) "; } - // NOTE: we sort by fave time, not by notice time! - - $qry .= 'ORDER BY original.id DESC '; + $qry .= 'ORDER BY original.created, original.id DESC '; if (!is_null($offset)) { $qry .= "LIMIT $limit OFFSET $offset";