Possible API speed ups for public timeline
This commit is contained in:
parent
a0bf5f8e34
commit
1fbf6c014b
1 changed files with 60 additions and 34 deletions
|
@ -1612,40 +1612,62 @@ function api_statuses_public_timeline($type)
|
||||||
|
|
||||||
$start = $page * $count;
|
$start = $page * $count;
|
||||||
|
|
||||||
|
if ($exclude_replies && !$conversation_id) {
|
||||||
|
if ($max_id > 0) {
|
||||||
|
$sql_extra = 'AND `thread`.`iid` <= ' . intval($max_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$r = dba::p("SELECT " . item_fieldlists() . "
|
||||||
|
FROM `thread`
|
||||||
|
STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
|
||||||
|
" . item_joins() . "
|
||||||
|
STRAIGHT_JOIN `user` ON `user`.`uid` = `thread`.`uid`
|
||||||
|
AND NOT `user`.`hidewall`
|
||||||
|
AND `verb` = ?
|
||||||
|
AND NOT `thread`.`private`
|
||||||
|
AND `thread`.`wall`
|
||||||
|
AND `thread`.`visible`
|
||||||
|
AND NOT `thread`.`deleted`
|
||||||
|
AND NOT `thread`.`moderated`
|
||||||
|
AND `thread`.`iid` > ?
|
||||||
|
$sql_extra
|
||||||
|
ORDER BY `thread`.`iid` DESC
|
||||||
|
LIMIT " . intval($start) . ", " . intval($count),
|
||||||
|
ACTIVITY_POST,
|
||||||
|
$since_id
|
||||||
|
);
|
||||||
|
|
||||||
|
$r = dba::inArray($r);
|
||||||
|
} else {
|
||||||
if ($max_id > 0) {
|
if ($max_id > 0) {
|
||||||
$sql_extra = 'AND `item`.`id` <= ' . intval($max_id);
|
$sql_extra = 'AND `item`.`id` <= ' . intval($max_id);
|
||||||
}
|
}
|
||||||
if ($exclude_replies > 0) {
|
|
||||||
$sql_extra .= ' AND `item`.`parent` = `item`.`id`';
|
|
||||||
}
|
|
||||||
if ($conversation_id > 0) {
|
if ($conversation_id > 0) {
|
||||||
$sql_extra .= ' AND `item`.`parent` = ' . intval($conversation_id);
|
$sql_extra .= ' AND `item`.`parent` = ' . intval($conversation_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q(
|
$r = dba::p("SELECT " . item_fieldlists() . "
|
||||||
"SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
|
|
||||||
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
|
|
||||||
`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
|
|
||||||
`contact`.`id` AS `cid`,
|
|
||||||
`user`.`nickname`, `user`.`hidewall`
|
|
||||||
FROM `item`
|
FROM `item`
|
||||||
STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid`
|
" . item_joins() . "
|
||||||
AND (NOT `contact`.`blocked` OR `contact`.`pending`)
|
|
||||||
STRAIGHT_JOIN `user` ON `user`.`uid` = `item`.`uid`
|
STRAIGHT_JOIN `user` ON `user`.`uid` = `item`.`uid`
|
||||||
AND NOT `user`.`hidewall`
|
AND NOT `user`.`hidewall`
|
||||||
WHERE `verb` = '%s' AND `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
|
AND `verb` = ?
|
||||||
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
|
AND NOT `item`.`private`
|
||||||
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
|
AND `item`.`wall`
|
||||||
AND NOT `item`.`private` AND `item`.`wall`
|
AND `item`.`visible`
|
||||||
|
AND NOT `item`.`deleted`
|
||||||
|
AND NOT `item`.`moderated`
|
||||||
|
AND `item`.`id` > ?
|
||||||
$sql_extra
|
$sql_extra
|
||||||
AND `item`.`id`>%d
|
ORDER BY `item`.`id` DESC
|
||||||
ORDER BY `item`.`id` DESC LIMIT %d, %d ",
|
LIMIT " . intval($start) . ", " . intval($count),
|
||||||
dbesc(ACTIVITY_POST),
|
ACTIVITY_POST,
|
||||||
intval($since_id),
|
$since_id
|
||||||
intval($start),
|
|
||||||
intval($count)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$r = dba::inArray($r);
|
||||||
|
}
|
||||||
|
|
||||||
$ret = api_format_items($r, $user_info, false, $type);
|
$ret = api_format_items($r, $user_info, false, $type);
|
||||||
|
|
||||||
$data = array('status' => $ret);
|
$data = array('status' => $ret);
|
||||||
|
@ -1697,11 +1719,15 @@ function api_statuses_networkpublic_timeline($type)
|
||||||
|
|
||||||
$r = dba::p("SELECT " . item_fieldlists() . "
|
$r = dba::p("SELECT " . item_fieldlists() . "
|
||||||
FROM `thread`
|
FROM `thread`
|
||||||
INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
|
STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
|
||||||
" . item_joins() . "
|
" . item_joins() . "
|
||||||
WHERE `thread`.`uid` = 0
|
WHERE `thread`.`uid` = 0
|
||||||
AND `verb` = ?
|
AND `verb` = ?
|
||||||
AND `item`.`id` > ?
|
AND NOT `thread`.`private`
|
||||||
|
AND `thread`.`visible`
|
||||||
|
AND NOT `thread`.`deleted`
|
||||||
|
AND NOT `thread`.`moderated`
|
||||||
|
AND `thread`.`iid` > ?
|
||||||
$sql_extra
|
$sql_extra
|
||||||
ORDER BY `thread`.`iid` DESC
|
ORDER BY `thread`.`iid` DESC
|
||||||
LIMIT " . intval($start) . ", " . intval($count),
|
LIMIT " . intval($start) . ", " . intval($count),
|
||||||
|
|
Loading…
Reference in a new issue