mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-03 18:04:08 +02:00
use the most common name for users on profile listing
This commit is contained in:
parent
73469d2aa1
commit
fba3778787
2 changed files with 15 additions and 2 deletions
|
|
@ -5,7 +5,7 @@ php:
|
|||
- '7.3'
|
||||
|
||||
addons:
|
||||
postgresql: "9.6"
|
||||
postgresql: "11"
|
||||
|
||||
cache:
|
||||
directories:
|
||||
|
|
|
|||
|
|
@ -47,12 +47,25 @@ class UserProvider extends BaseProvider {
|
|||
}
|
||||
|
||||
public function get(string $steamid): ?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('steamid', $query->createNamedParameter($steamid)));
|
||||
|
||||
$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('steamid', $query->createNamedParameter($steamid)));
|
||||
|
||||
$row = $query->execute()->fetch();
|
||||
}
|
||||
|
||||
return $row ? User::fromRow($row) : null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue