Update sorting for user tagged timelines (indexing was bad before and remains bad -- we need some DB changes to make this one nice)
This commit is contained in:
parent
4cd3a0756b
commit
4adf551f9f
@ -215,26 +215,29 @@ class Profile extends Memcached_DataObject
|
|||||||
function _streamTaggedDirect($tag, $offset, $limit, $since_id, $max_id)
|
function _streamTaggedDirect($tag, $offset, $limit, $since_id, $max_id)
|
||||||
{
|
{
|
||||||
// XXX It would be nice to do this without a join
|
// XXX It would be nice to do this without a join
|
||||||
|
// (necessary to do it efficiently on accounts with long history)
|
||||||
|
|
||||||
$notice = new Notice();
|
$notice = new Notice();
|
||||||
|
|
||||||
$query =
|
$query =
|
||||||
"select id from notice join notice_tag on id=notice_id where tag='".
|
"select id from notice join notice_tag on id=notice_id where tag='".
|
||||||
$notice->escape($tag) .
|
$notice->escape($tag) .
|
||||||
"' and profile_id=" . $notice->escape($this->id);
|
"' and profile_id=" . intval($this->id);
|
||||||
|
|
||||||
if ($since_id != 0) {
|
$since = Notice::whereSinceId($since_id, 'id', 'notice.created');
|
||||||
$query .= " and id > $since_id";
|
if ($since) {
|
||||||
|
$query .= " and ($since)";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($max_id != 0) {
|
$max = Notice::whereMaxId($max_id, 'id', 'notice.created');
|
||||||
$query .= " and id <= $max_id";
|
if ($max) {
|
||||||
|
$query .= " and ($max)";
|
||||||
}
|
}
|
||||||
|
|
||||||
$query .= ' order by id DESC';
|
$query .= ' order by notice.created DESC, id DESC';
|
||||||
|
|
||||||
if (!is_null($offset)) {
|
if (!is_null($offset)) {
|
||||||
$query .= " LIMIT $limit OFFSET $offset";
|
$query .= " LIMIT " . intval($limit) . " OFFSET " . intval($offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
$notice->query($query);
|
$notice->query($query);
|
||||||
|
Loading…
Reference in New Issue
Block a user