Some speed improvements

This commit is contained in:
Michael 2017-01-15 12:23:40 +00:00
parent 7b24476b81
commit 21605a52c9
3 changed files with 10 additions and 4 deletions

View File

@ -434,7 +434,7 @@ function gpluspost_init() {
foreach ($items AS $item)
gpluspost_feeditem($item, $uid);
} else {
$items = q("SELECT `id` FROM `item` FORCE INDEX (`received`) WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `item`.`id` = `item`.`parent` ORDER BY `received` DESC LIMIT 10");
$items = q("SELECT `id` FROM `item` WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `item`.`id` = `item`.`parent` ORDER BY `received` DESC LIMIT 10");
foreach ($items AS $item)
gpluspost_feeditem($item["id"], $uid);
}

View File

@ -550,7 +550,8 @@ function jappixmini_cron(&$a, $d) {
$uid = $row["uid"];
// for each user, go through list of contacts
$contacts = q("SELECT * FROM `contact` WHERE `uid`=%d AND ((LENGTH(`dfrn-id`) AND LENGTH(`pubkey`)) OR (LENGTH(`issued-id`) AND LENGTH(`prvkey`)))", intval($uid));
$contacts = q("SELECT * FROM `contact` WHERE `uid`=%d AND ((LENGTH(`dfrn-id`) AND LENGTH(`pubkey`)) OR (LENGTH(`issued-id`) AND LENGTH(`prvkey`))) AND `network` = '%s'",
intval($uid), dbesc(NETWORK_DFRN));
foreach ($contacts as $contact_row) {
$request = $contact_row["request"];
if (!$request) continue;

View File

@ -864,6 +864,11 @@ function pumpio_dounlike(&$a, $uid, $self, $post, $own_id) {
function pumpio_dolike(&$a, $uid, $self, $post, $own_id, $threadcompletion = true) {
require_once('include/items.php');
if ($post->object->id == "") {
logger('Got empty like: '.print_r($post, true), LOGGER_DEBUG);
return;
}
// Searching for the liked post
// Two queries for speed issues
$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d AND `network` = '%s' LIMIT 1",
@ -899,8 +904,8 @@ function pumpio_dolike(&$a, $uid, $self, $post, $own_id, $threadcompletion = tru
$post->actor->url = $self[0]['url'];
$post->actor->image->url = $self[0]['photo'];
} else {
$r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
dbesc($post->actor->url),
$r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
dbesc(normalise_link($post->actor->url)),
intval($uid)
);