summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-12-17 13:45:40 -0800
committerBrion Vibber <brion@pobox.com>2010-12-17 13:45:40 -0800
commit4adf551f9fe73209bf44afb2960667bb62d66c6f (patch)
tree551115deb433d6da3ddbbc55f8100ca282226849
parent4cd3a0756bdfba4589dbf1efeab9a2a509e9d566 (diff)
Update sorting for user tagged timelines (indexing was bad before and remains bad -- we need some DB changes to make this one nice)
-rw-r--r--classes/Profile.php17
1 files changed, 10 insertions, 7 deletions
diff --git a/classes/Profile.php b/classes/Profile.php
index 62789a489..fe1a070bd 100644
--- a/classes/Profile.php
+++ b/classes/Profile.php
@@ -215,26 +215,29 @@ class Profile extends Memcached_DataObject
function _streamTaggedDirect($tag, $offset, $limit, $since_id, $max_id)
{
// XXX It would be nice to do this without a join
+ // (necessary to do it efficiently on accounts with long history)
$notice = new Notice();
$query =
"select id from notice join notice_tag on id=notice_id where tag='".
$notice->escape($tag) .
- "' and profile_id=" . $notice->escape($this->id);
+ "' and profile_id=" . intval($this->id);
- if ($since_id != 0) {
- $query .= " and id > $since_id";
+ $since = Notice::whereSinceId($since_id, 'id', 'notice.created');
+ if ($since) {
+ $query .= " and ($since)";
}
- if ($max_id != 0) {
- $query .= " and id <= $max_id";
+ $max = Notice::whereMaxId($max_id, 'id', 'notice.created');
+ if ($max) {
+ $query .= " and ($max)";
}
- $query .= ' order by id DESC';
+ $query .= ' order by notice.created DESC, id DESC';
if (!is_null($offset)) {
- $query .= " LIMIT $limit OFFSET $offset";
+ $query .= " LIMIT " . intval($limit) . " OFFSET " . intval($offset);
}
$notice->query($query);