Skip to content

Commit 2ec03bf

Browse files
authored
Merge branch 'master' into realtime-multiplayer-fail-allowance
2 parents 072be8b + f1e68a7 commit 2ec03bf

14 files changed

+411
-481
lines changed

app/Http/Controllers/BeatmapsController.php

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ private static function beatmapScores(string $id, ?string $scoreTransformerType,
7979
$scoreTransformer = new ScoreTransformer($scoreTransformerType);
8080

8181
$results = [
82+
'score_count' => UserRank::getCount($esFetch->baseParams),
8283
'scores' => json_collection(
8384
$scores,
8485
$scoreTransformer,

app/Http/Controllers/BeatmapsetsController.php

+2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ public function show($id)
112112
}
113113

114114
/**
115+
* Search Beatmapset
116+
*
115117
* TODO: documentation
116118
*
117119
* @usesCursor

app/Libraries/Score/BeatmapScores.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
class BeatmapScores
1616
{
17+
public ScoreSearchParams $baseParams;
1718
public array $result;
18-
private ScoreSearchParams $baseParams;
1919

2020
public function __construct(private array $rawParams)
2121
{
@@ -48,7 +48,6 @@ public function rank(SoloScore $score): int
4848

4949
$params = clone $this->baseParams;
5050
$params->beforeScore = $score;
51-
$params->setSort(null);
5251

5352
return UserRank::getRank($params);
5453
}

app/Libraries/Score/UserRank.php

+12-6
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,9 @@
1111

1212
class UserRank
1313
{
14-
public static function getRank(ScoreSearchParams $params): int
14+
public static function getCount(ScoreSearchParams $params): int
1515
{
16-
if ($params->beforeTotalScore === null && $params->beforeScore === null) {
17-
throw new InvariantException('beforeScore or beforeTotalScore must be specified');
18-
}
19-
16+
$params->setSort(null);
2017
$search = new ScoreSearch($params);
2118

2219
$search->size(0);
@@ -27,6 +24,15 @@ public static function getRank(ScoreSearchParams $params): int
2724
$response = $search->response();
2825
$search->assertNoError();
2926

30-
return 1 + $response->aggregations($aggName)['value'];
27+
return $response->aggregations($aggName)['value'];
28+
}
29+
30+
public static function getRank(ScoreSearchParams $params): int
31+
{
32+
if ($params->beforeTotalScore === null && $params->beforeScore === null) {
33+
throw new InvariantException('beforeScore or beforeTotalScore must be specified');
34+
}
35+
36+
return 1 + static::getCount($params);
3137
}
3238
}

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@
5252
"require-dev": {
5353
"beyondcode/laravel-query-detector": "*",
5454
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
55-
"dms/phpunit-arraysubset-asserts": "^0.3.0",
55+
"dms/phpunit-arraysubset-asserts": "^0.5.0",
5656
"laravel/dusk": "*",
5757
"mockery/mockery": "*",
5858
"nunomaduro/collision": "^6.1",
59-
"phpunit/phpunit": ">=9.5",
59+
"phpunit/phpunit": ">=10.0",
6060
"slevomat/coding-standard": "^8.15",
6161
"spatie/laravel-ignition": "^2.0",
6262
"squizlabs/php_codesniffer": "^3.10",

0 commit comments

Comments
 (0)