Add following/followers/statuses to search result
This commit is contained in:
parent
1aa7682a91
commit
dc71b89d3e
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue