aboutsummaryrefslogtreecommitdiffstats
path: root/include/security.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2015-03-23 19:56:10 -0700
committerfriendica <info@friendica.com>2015-03-23 19:56:10 -0700
commitc2acab21d44bfaa8e051a42a13b72c056c95b0a3 (patch)
tree9bed606355434db496ecca9aaca04fcac4993381 /include/security.php
parentd32f63df82de01f66d5babe932f20aed9a5b3ee2 (diff)
downloadvolse-hubzilla-c2acab21d44bfaa8e051a42a13b72c056c95b0a3.tar.gz
volse-hubzilla-c2acab21d44bfaa8e051a42a13b72c056c95b0a3.tar.bz2
volse-hubzilla-c2acab21d44bfaa8e051a42a13b72c056c95b0a3.zip
improve performance of the zotfeed queries
Diffstat (limited to 'include/security.php')
-rw-r--r--include/security.php6
1 files changed, 4 insertions, 2 deletions
diff --git a/include/security.php b/include/security.php
index e9b41dcf9..c3b0e9763 100644
--- a/include/security.php
+++ b/include/security.php
@@ -396,13 +396,15 @@ function init_groups_visitor($contact_id) {
// will likely be too expensive.
// Returns a string list of comma separated channel_ids suitable for direct inclusion in a SQL query
-function stream_perms_api_uids($perms = NULL ) {
+function stream_perms_api_uids($perms = NULL, $limit = 0, $rand = 0 ) {
$perms = is_null($perms) ? (PERMS_SITE|PERMS_NETWORK|PERMS_PUBLIC) : $perms;
$ret = array();
+ $limit_sql = (($limit) ? " LIMIT " . intval($limit) . " " : '');
+ $random_sql = (($rand) ? " ORDER BY " . db_getfunc('RAND') . " " : '');
if(local_channel())
$ret[] = local_channel();
- $r = q("select channel_id from channel where channel_r_stream > 0 and (channel_r_stream & %d)>0 and not (channel_pageflags & %d)>0",
+ $r = q("select channel_id from channel where channel_r_stream > 0 and ( channel_r_stream & %d )>0 and ( channel_pageflags & %d ) = 0 $random_sql $limit_sql ",
intval($perms),
intval(PAGE_ADULT|PAGE_CENSORED|PAGE_SYSTEM|PAGE_REMOVED)
);