Add following/followers/statuses to search result

This commit is contained in:
Bofh 2022-12-01 01:17:41 +01:00
parent 1aa7682a91
commit dc71b89d3e
2 changed files with 14 additions and 0 deletions

View File

@ -136,7 +136,16 @@ foreach ($filtered_accounts as $id) {
$newacc['avatar'] .= '/cache';
$newacc['avatar'] .= '/accounts/avatars/'.implode('/',$parts).'/original/'.$account['avatar_file_name'];
}
$following = $pg->fetch_one('SELECT count(1) FROM follows WHERE account_id = \''.$id.'\'');
$newacc['following'] = intval($following['count']);
$followers = $pg->fetch_one('SELECT count(1) FROM follows WHERE target_account_id = \''.$id.'\'');
$newacc['followers'] = intval($followers['count']);
$statuses = $pg->fetch_one('SELECT count(1) FROM statuses WHERE account_id = \''.$id.'\'');
$newacc['statuses'] = intval($statuses['count']);
$result_accounts []= $newacc;
}
$pg->close();
apiresult($result_accounts);

View File

@ -36,6 +36,11 @@ class PgDatabase {
return $result;
}
public function fetch_one($sql) {
$result = $this->query($sql);
return pg_fetch_assoc($result);
}
public function fetch_all($sql) {
$data = [];
$result = $this->query($sql);