Skip to content

Commit 7bb0ae2

Browse files
RushawayA1mDev
andcommitted
Fix Issue A1mDev#26
Co-Authored-By: A1m` <33463136+a1mdev@users.noreply.github.com>
1 parent b1bc36a commit 7bb0ae2

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

web/classes/Repository/PlayerRepository.php

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public function getPlayerSkillHistory(int $player, int $limit = 30) : ?array
5858
public function getPlayerSuggestions(string $game, string $search, int $limit = 30) : ?array
5959
{
6060
$limit = max(1, $limit);
61+
6162
$sql = "
6263
SELECT DISTINCT
6364
hlstats_PlayerNames.name
@@ -83,7 +84,7 @@ public function getPlayerSuggestions(string $game, string $search, int $limit =
8384
$stmt->execute();
8485

8586
return $stmt->fetchAll(PDO::FETCH_COLUMN);
86-
} catch (\PDOException $e) {
87+
} catch (PDOException $e) {
8788
$this->logger->error('PDO Exception in getPlayerSuggestions: ' . $e->getMessage());
8889
return null;
8990
}
@@ -93,18 +94,14 @@ public function getPlayerRank(string $game, string $rankingType, int $playerPoin
9394
{
9495
$allowedRankingType = $this->optionService->getRankingTypeChoices();
9596
if (empty($allowedRankingType)) {
96-
$allowedRankingType = ['kills', 'skill']; // default params
97+
$allowedRankingType = ['kills', 'skill'];
9798
}
9899

99100
if (!in_array($rankingType, $allowedRankingType, true)) {
100101
return null;
101102
}
102103

103-
$tempDeaths = $playerDeaths;
104-
if ($tempDeaths == 0) {
105-
$tempDeaths = 1;
106-
}
107-
104+
$tempDeaths = $playerDeaths ?: 1;
108105
$kpd = $playerKills / $tempDeaths;
109106

110107
$sql = "
@@ -119,9 +116,9 @@ public function getPlayerRank(string $game, string $rankingType, int $playerPoin
119116
AND
120117
kills >= 1
121118
AND (
122-
{$rankingType} > :points
119+
{$rankingType} > :points1
123120
OR (
124-
{$rankingType} = :points_eq
121+
{$rankingType} = :points2
125122
AND (kills / IF(deaths = 0, 1, deaths) > :kpd)
126123
)
127124
)
@@ -131,10 +128,10 @@ public function getPlayerRank(string $game, string $rankingType, int $playerPoin
131128
$stmt = $this->pdo->prepare($sql);
132129

133130
$stmt->execute([
134-
'game' => $game,
135-
'points' => $playerPoints,
136-
'points_eq' => $playerPoints,
137-
'kpd' => $kpd,
131+
'game' => $game,
132+
'points1' => $playerPoints,
133+
'points2' => $playerPoints,
134+
'kpd' => $kpd,
138135
]);
139136

140137
$count = $stmt->fetchColumn();

0 commit comments

Comments
 (0)