mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-04 02:14:06 +02:00
use userprovider to get uploader data
This commit is contained in:
parent
0d803526d8
commit
9bf9721190
8 changed files with 47 additions and 17 deletions
|
|
@ -70,6 +70,30 @@ class UserProvider extends BaseProvider {
|
|||
return $row ? User::fromRow($row) : null;
|
||||
}
|
||||
|
||||
public function getById(int $userId): ?User {
|
||||
// first search in the view which contains the most used name for the users
|
||||
|
||||
$query = $this->getQueryBuilder();
|
||||
$query->select(['id', 'steamid', 'name', 'avatar', 'token'])
|
||||
->from('users_named')
|
||||
->where($query->expr()->eq('id', $query->createNamedParameter($userId, \PDO::PARAM_INT)));
|
||||
|
||||
$row = $query->execute()->fetch();
|
||||
|
||||
if (!$row) {
|
||||
// if the user is newly inserted it wont be in our view yet
|
||||
|
||||
$query = $this->getQueryBuilder();
|
||||
$query->select(['id', 'steamid', 'name', 'avatar', 'token'])
|
||||
->from('users')
|
||||
->where($query->expr()->eq('id', $query->createNamedParameter($userId, \PDO::PARAM_INT)));
|
||||
|
||||
$row = $query->execute()->fetch();
|
||||
}
|
||||
|
||||
return $row ? User::fromRow($row) : null;
|
||||
}
|
||||
|
||||
private function searchBySteamId(string $steamId): ?array {
|
||||
$query = $this->getQueryBuilder();
|
||||
$query->select('u.id', 'p.name', 'count(demo_id) as count', 'steamid')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue