From c392a77b46958555bc16592fe4d57e9ab0b7e126 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 15 Nov 2022 21:22:10 +0000 Subject: performance: just count the first 99 unseen items and display 99+ if there are more than 99 --- Zotlabs/Module/Sse_bs.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'Zotlabs/Module/Sse_bs.php') diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php index 3a4e4e09e..4aabcafcb 100644 --- a/Zotlabs/Module/Sse_bs.php +++ b/Zotlabs/Module/Sse_bs.php @@ -205,18 +205,18 @@ class Sse_bs extends Controller { } - $r = q("SELECT count(id) as total FROM item + $r = q("SELECT id FROM item WHERE uid = %d and item_unseen = 1 AND item_wall = 0 AND item_private IN (0, 1) AND obj_type NOT IN ('Document', 'Video', 'Audio', 'Image') AND author_xchan != '%s' $item_normal - $sql_extra", + $sql_extra LIMIT 100", intval(self::$uid), dbesc(self::$ob_hash) ); if($r) - $result['network']['count'] = intval($r[0]['total']); + $result['network']['count'] = count($r); return $result; } @@ -285,17 +285,17 @@ class Sse_bs extends Controller { } - $r = q("SELECT count(id) as total FROM item + $r = q("SELECT id FROM item WHERE uid = %d and item_unseen = 1 AND item_private = 2 $item_normal $sql_extra - AND author_xchan != '%s'", + AND author_xchan != '%s' LIMIT 100", intval(self::$uid), dbesc(self::$ob_hash) ); if($r) - $result['dm']['count'] = intval($r[0]['total']); + $result['dm']['count'] = count($r); return $result; } @@ -365,17 +365,17 @@ class Sse_bs extends Controller { } - $r = q("SELECT count(id) as total FROM item + $r = q("SELECT id FROM item WHERE uid = %d and item_unseen = 1 AND item_wall = 1 AND item_private IN (0, 1) $item_normal $sql_extra - AND author_xchan != '%s'", + AND author_xchan != '%s' LIMIT 100", intval(self::$uid), dbesc(self::$ob_hash) ); if($r) - $result['home']['count'] = intval($r[0]['total']); + $result['home']['count'] = count($r); return $result; } @@ -458,19 +458,19 @@ class Sse_bs extends Controller { } - $r = q("SELECT count(id) as total FROM item + $r = q("SELECT id FROM item WHERE uid = %d AND item_unseen = 1 AND created > '%s' $item_normal $sql_extra - AND author_xchan != '%s'", + AND author_xchan != '%s' LIMIT 100", intval($sys['channel_id']), dbescdate($_SESSION['static_loadtime']), dbesc(self::$ob_hash) ); if($r) - $result['pubs']['count'] = intval($r[0]['total']); + $result['pubs']['count'] = count($r); return $result; } -- cgit v1.2.3