Make statuses (count) retrieved on the SQL query instead
This commit is contained in:
parent
87158897ad
commit
d54d60bc9f
|
@ -17,7 +17,8 @@ $filtered_accounts_index = [];
|
|||
$sql_all = '
|
||||
SELECT
|
||||
a.id, a.username, a.domain, a.fields, a.note, a.avatar_file_name,
|
||||
a.avatar_storage_schema_version
|
||||
a.avatar_storage_schema_version,
|
||||
(SELECT count(1) FROM statuses WHERE account_id = a.id) AS statuses
|
||||
FROM accounts AS a
|
||||
{userLocalInnerJoin}
|
||||
WHERE
|
||||
|
@ -25,6 +26,7 @@ $sql_all = '
|
|||
{userLocalWhere1}
|
||||
{userLocalWhere2}
|
||||
{noAvatarWhere}
|
||||
{noStatusesWhere}
|
||||
a.suspended_at IS NULL
|
||||
ORDER BY a.updated_at DESC
|
||||
';
|
||||
|
@ -58,9 +60,11 @@ switch ($user_filter) {
|
|||
|
||||
if (isset($_GET['no_avatar']))
|
||||
$sql_all = str_replace('{noAvatarWhere}', 'a.avatar_file_name IS NULL AND', $sql_all);
|
||||
else
|
||||
$sql_all = str_replace('{noAvatarWhere}', '', $sql_all);
|
||||
else $sql_all = str_replace('{noAvatarWhere}', '', $sql_all);
|
||||
|
||||
if (isset($_GET['no_statuses']))
|
||||
$sql_all = str_replace('{noStatusesWhere}', '(SELECT count(1) FROM statuses WHERE account_id = a.id) = 0 AND', $sql_all);
|
||||
else $sql_all = str_replace('{noStatusesWhere}', '', $sql_all);
|
||||
|
||||
$all_accounts = $pg->fetch_all($sql_all);
|
||||
|
||||
|
@ -127,6 +131,7 @@ foreach ($filtered_accounts as $id) {
|
|||
$newacc['acct'] = trim($newacc['acct'],'@');
|
||||
$newacc['note'] = $account['note'];
|
||||
$newacc['fields'] = $account['fields'];
|
||||
$newacc['statuses'] = intval($account['statuses']);
|
||||
if ($account['avatar_storage_schema_version'] === 1) {
|
||||
$c = 0;
|
||||
$parts = [];
|
||||
|
@ -153,11 +158,6 @@ foreach ($filtered_accounts as $id) {
|
|||
if (isset($_GET['no_follows']) && $newacc['following'] > 0 && $newacc['followers'] > 0)
|
||||
continue;
|
||||
|
||||
$statuses = $pg->fetch_one('SELECT count(1) FROM statuses WHERE account_id = \''.$id.'\'');
|
||||
$newacc['statuses'] = intval($statuses['count']);
|
||||
if (isset($_GET['no_statuses']) && $newacc['statuses'] > 0)
|
||||
continue;
|
||||
|
||||
$result_accounts []= $newacc;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue