Small performance improvements
This commit is contained in:
parent
89227813fc
commit
84e84a0689
|
@ -481,11 +481,11 @@ function acl_lookup(&$a, $out_type = 'json') {
|
||||||
if ($type=='' || $type=='g'){
|
if ($type=='' || $type=='g'){
|
||||||
|
|
||||||
$r = q("SELECT `group`.`id`, `group`.`name`, GROUP_CONCAT(DISTINCT `group_member`.`contact-id` SEPARATOR ',') AS uids
|
$r = q("SELECT `group`.`id`, `group`.`name`, GROUP_CONCAT(DISTINCT `group_member`.`contact-id` SEPARATOR ',') AS uids
|
||||||
FROM `group`,`group_member`
|
FROM `group`
|
||||||
WHERE `group`.`deleted` = 0 AND `group`.`uid` = %d
|
INNER JOIN `group_member` ON `group_member`.`gid`=`group`.`id` AND `group_member`.`uid` = `group`.`uid`
|
||||||
AND `group_member`.`gid`=`group`.`id`
|
WHERE NOT `group`.`deleted` AND `group`.`uid` = %d
|
||||||
$sql_extra
|
$sql_extra
|
||||||
GROUP BY `group`.`id`
|
GROUP BY `group`.`name`
|
||||||
ORDER BY `group`.`name`
|
ORDER BY `group`.`name`
|
||||||
LIMIT %d,%d",
|
LIMIT %d,%d",
|
||||||
intval(local_user()),
|
intval(local_user()),
|
||||||
|
|
|
@ -872,7 +872,8 @@ function contact_block() {
|
||||||
$micropro = Null;
|
$micropro = Null;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$r = q("SELECT `id`, `uid`, `addr`, `url`, `name`, `thumb`, `network` FROM `contact`
|
// Splitting the query in two parts makes it much faster
|
||||||
|
$r = q("SELECT `id` FROM `contact`
|
||||||
WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending`
|
WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending`
|
||||||
AND NOT `hidden` AND NOT `archive`
|
AND NOT `hidden` AND NOT `archive`
|
||||||
AND `network` IN ('%s', '%s', '%s') ORDER BY RAND() LIMIT %d",
|
AND `network` IN ('%s', '%s', '%s') ORDER BY RAND() LIMIT %d",
|
||||||
|
@ -882,11 +883,19 @@ function contact_block() {
|
||||||
dbesc(NETWORK_DIASPORA),
|
dbesc(NETWORK_DIASPORA),
|
||||||
intval($shown)
|
intval($shown)
|
||||||
);
|
);
|
||||||
if(count($r)) {
|
if ($r) {
|
||||||
$contacts = sprintf( tt('%d Contact','%d Contacts', $total),$total);
|
$contacts = "";
|
||||||
$micropro = Array();
|
foreach ($r AS $contact)
|
||||||
foreach($r as $rr) {
|
$contacts[] = $contact["id"];
|
||||||
$micropro[] = micropro($rr,true,'mpfriend');
|
|
||||||
|
$r = q("SELECT `id`, `uid`, `addr`, `url`, `name`, `thumb`, `network` FROM `contact` WHERE `id` IN (%s)",
|
||||||
|
dbesc(implode(",", $contacts)));
|
||||||
|
if(count($r)) {
|
||||||
|
$contacts = sprintf( tt('%d Contact','%d Contacts', $total),$total);
|
||||||
|
$micropro = Array();
|
||||||
|
foreach($r as $rr) {
|
||||||
|
$micropro[] = micropro($rr,true,'mpfriend');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue