MAPG-235 queries with selected relations enabled; reduced size of some of the queries
This commit is contained in:
1 parent
7898c52328
commit
a7cfc3c19f
7 files changed
+67
-103
No files matched your search
@@ -41,15 +41,20 @@ class UserInChallengeRepository
|
||||
return $this->pdm->selectFromDb($select, UserInChallenge::class);
|
||||
}
|
||||
|
||||
public function getByUserIdAndToken(int $userId, string $token_str): ?UserInChallenge
|
||||
public function getByUserIdAndToken(int $userId, string $token_str, array $withRelations = []): ?UserInChallenge
|
||||
{
|
||||
if (count($withRelations)) {
|
||||
$necessaryRelations = [Challenge::class];
|
||||
$withRelations = array_unique(array_merge($withRelations, $necessaryRelations));
|
||||
}
|
||||
|
||||
$token = hexdec($token_str);
|
||||
|
||||
$select = new Select(\Container::$dbConnection);
|
||||
$select->where('user_id', '=', $userId);
|
||||
$select->where('token', '=', $token);
|
||||
|
||||
return $this->pdm->selectFromDb($select, UserInChallenge::class, true);
|
||||
return $this->pdm->selectFromDb($select, UserInChallenge::class, true, $withRelations);
|
||||
}
|
||||
|
||||
public function isUserParticipatingInChallenge(int $userId, Challenge $challenge): bool
|
||||
|
||||
Reference in new issue
Block a user