Skip to content

Commit a2c7f73

Browse files
authoredMar 4, 2024
Merge branch 'master' into singletons
2 parents 7cd2710 + 1b94e15 commit a2c7f73

29 files changed

+142
-135
lines changed
 

Diff for: ‎.github/workflows/lint.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ jobs:
1515

1616
steps:
1717
- name: Checkout
18-
uses: actions/checkout@v3
18+
uses: actions/checkout@v4
1919

2020
- name: Setup node.js
21-
uses: actions/setup-node@v3
21+
uses: actions/setup-node@v4
2222
with:
2323
cache: yarn
24-
node-version: '18'
24+
node-version: '20'
2525

2626
- name: Set php version
2727
uses: shivammathur/setup-php@v2
@@ -35,7 +35,7 @@ jobs:
3535
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
3636

3737
- name: Cache composer
38-
uses: actions/cache@v3
38+
uses: actions/cache@v4
3939
with:
4040
path: ${{ steps.composercache.outputs.dir }}
4141
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}

Diff for: ‎.github/workflows/tests.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ jobs:
9999
runs-on: ubuntu-latest
100100
steps:
101101
- name: Checkout
102-
uses: actions/checkout@v3
102+
uses: actions/checkout@v4
103103

104104
- name: Services
105105
run: 'docker compose up --quiet-pull --wait
@@ -112,10 +112,10 @@ jobs:
112112
'
113113

114114
- name: Setup node.js
115-
uses: actions/setup-node@v3
115+
uses: actions/setup-node@v4
116116
with:
117117
cache: yarn
118-
node-version: '18'
118+
node-version: '20'
119119

120120
- name: Set php version
121121
uses: shivammathur/setup-php@v2
@@ -130,7 +130,7 @@ jobs:
130130
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
131131

132132
- name: Cache composer
133-
uses: actions/cache@v3
133+
uses: actions/cache@v4
134134
with:
135135
path: ${{ steps.composercache.outputs.dir }}
136136
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}

Diff for: ‎app/Http/Controllers/Forum/PostsController.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,14 @@ public function raw($id)
143143
{
144144
$post = Post::withTrashed()->findOrFail($id);
145145

146-
if ($post->trashed()) {
147-
priv_check('ForumModerate', $post->forum)->ensureCan();
148-
}
149-
150146
if ($post->forum === null || $post->topic === null) {
151147
abort(404);
152148
}
153149

150+
if ($post->trashed() || $post->topic->trashed()) {
151+
priv_check('ForumModerate', $post->forum)->ensureCan();
152+
}
153+
154154
priv_check('ForumView', $post->forum)->ensureCan();
155155

156156
$text = $post->bodyRaw;

Diff for: ‎app/Http/Controllers/Multiplayer/Rooms/Playlist/ScoresController.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function index($roomId, $playlistId)
104104
*
105105
* ### Response Format
106106
*
107-
* Returns [MultiplayerScore](#multiplayerscore) object.
107+
* Returns [Score](#score) object.
108108
*
109109
* @urlParam room integer required Id of the room.
110110
* @urlParam playlist integer required Id of the playlist item.
@@ -136,7 +136,7 @@ public function show($roomId, $playlistId, $id)
136136
*
137137
* ### Response Format
138138
*
139-
* Returns [MultiplayerScore](#multiplayerscore) object.
139+
* Returns [Score](#score) object.
140140
*
141141
* @urlParam room integer required Id of the room.
142142
* @urlParam playlist integer required Id of the playlist item.

Diff for: ‎app/Jobs/Notifications/UserAchievementUnlock.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111

1212
class UserAchievementUnlock extends BroadcastNotificationBase
1313
{
14-
const NOTIFICATION_OPTION_NAME = Notification::USER_ACHIEVEMENT_UNLOCK;
14+
// Mainly to ensure client always getting the event.
15+
// Also it probably doesn't really make sense to mail the event
16+
// in the first place.
17+
const DELIVERY_MODE_DEFAULTS = ['mail' => false, 'push' => true];
1518

1619
protected $achievement;
1720

Diff for: ‎app/Jobs/RemoveBeatmapsetSoloScores.php

+1-10
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use App\Models\Beatmap;
1212
use App\Models\Beatmapset;
1313
use App\Models\Solo\Score;
14-
use DB;
1514
use Illuminate\Bus\Queueable;
1615
use Illuminate\Contracts\Queue\ShouldQueue;
1716
use Illuminate\Database\Eloquent\Collection;
@@ -59,15 +58,7 @@ private function deleteScores(Collection $scores): void
5958
{
6059
$ids = $scores->pluck('id')->all();
6160

62-
$scoresQuery = Score::whereKey($ids);
63-
// Queue delete ahead of time in case process is stopped right after
64-
// db delete is committed. It's fine queuing deleted score ahead of
65-
// time as best score check doesn't use index.
66-
// Set the flag first so indexer will correctly delete it.
67-
$scoresQuery->update(['preserve' => false]);
61+
Score::whereKey($ids)->update(['ranked' => false]);
6862
$this->scoreSearch->queueForIndex($this->schemas, $ids);
69-
DB::transaction(function () use ($ids, $scoresQuery): void {
70-
$scoresQuery->delete();
71-
});
7263
}
7364
}

Diff for: ‎app/Models/Multiplayer/PlaylistItemUserHighScore.php

-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
* @property \Carbon\Carbon $created_at
1919
* @property int $id
2020
* @property int $playlist_item_id
21-
* @property float|null $pp
2221
* @property int $score_id
2322
* @property ScoreLink $scoreLink
2423
* @property int $total_score
@@ -51,7 +50,6 @@ public static function lookupOrDefault(int $userId, int $playlistItemId): static
5150
'user_id' => $userId,
5251
], [
5352
'accuracy' => 0,
54-
'pp' => 0,
5553
'total_score' => 0,
5654
]);
5755
}
@@ -122,7 +120,6 @@ public function updateWithScoreLink(ScoreLink $scoreLink): bool
122120

123121
return $this->fill([
124122
'accuracy' => $score->accuracy,
125-
'pp' => $score->pp,
126123
'score_id' => $score->getKey(),
127124
'total_score' => $score->total_score,
128125
])->save();

Diff for: ‎app/Models/Multiplayer/UserScoreAggregate.php

-8
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
* @property int $id
2121
* @property int|null $last_score_id
2222
* @property bool $in_room
23-
* @property float|null $pp
2423
* @property int $room_id
2524
* @property int $total_score
2625
* @property \Carbon\Carbon $updated_at
@@ -53,7 +52,6 @@ public static function lookupOrDefault(User $user, Room $room): static
5352
'accuracy' => 0,
5453
'attempts' => 0,
5554
'completed' => 0,
56-
'pp' => 0,
5755
'total_score' => 0,
5856
]);
5957
}
@@ -91,11 +89,6 @@ public function averageAccuracy()
9189
return $this->completed > 0 ? $this->accuracy / $this->completed : 0;
9290
}
9391

94-
public function averagePp()
95-
{
96-
return $this->completed > 0 ? $this->pp / $this->completed : 0;
97-
}
98-
9992
public function playlistItemAttempts(): array
10093
{
10194
$playlistItemAggs = PlaylistItemUserHighScore
@@ -159,7 +152,6 @@ public function removeRunningTotals()
159152
'attempts',
160153
'completed',
161154
'last_score_id',
162-
'pp',
163155
'total_score',
164156
];
165157

Diff for: ‎app/Models/Solo/Score.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use App\Libraries\Score\UserRank;
1414
use App\Libraries\Search\ScoreSearchParams;
1515
use App\Models\Beatmap;
16-
use App\Models\Beatmapset;
1716
use App\Models\Model;
1817
use App\Models\Multiplayer\ScoreLink as MultiplayerScoreLink;
1918
use App\Models\Score as LegacyScore;
@@ -120,10 +119,8 @@ public static function extractParams(array $rawParams, ScoreToken|MultiplayerSco
120119
$params['user_id'] = $scoreToken->user_id;
121120

122121
$beatmap = $scoreToken->beatmap;
123-
$params['ranked'] = $beatmap !== null && in_array($beatmap->approved, [
124-
Beatmapset::STATES['approved'],
125-
Beatmapset::STATES['ranked'],
126-
], true);
122+
// anything that have leaderboard
123+
$params['ranked'] = $beatmap !== null && $beatmap->approved > 0;
127124

128125
$params['preserve'] = $params['passed'] ?? false;
129126

@@ -164,6 +161,7 @@ public function scopeIndexable(Builder $query): Builder
164161
{
165162
return $query
166163
->where('preserve', true)
164+
->where('ranked', true)
167165
->whereHas('user', fn (Builder $q): Builder => $q->default());
168166
}
169167

@@ -427,6 +425,10 @@ public function url(): string
427425

428426
public function userRank(?array $params = null): int
429427
{
428+
if (!$this->ranked || !$this->preserve) {
429+
return 0;
430+
}
431+
430432
// Non-legacy score always has its rank checked against all score types.
431433
if (!$this->isLegacy()) {
432434
$params['is_legacy'] = null;

Diff for: ‎app/Models/Traits/Scoreable.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public function recalculateRank(): void
170170
private function shouldHaveHiddenRank(): bool
171171
{
172172
foreach ($this->enabled_mods as $mod) {
173-
if ($mod === 'FL' || $mod === 'HD') {
173+
if ($mod === 'FI' || $mod === 'FL' || $mod === 'HD') {
174174
return true;
175175
}
176176
}

Diff for: ‎app/Models/UserNotificationOption.php

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ class UserNotificationOption extends Model
3939
Notification::CHANNEL_MESSAGE,
4040
Notification::COMMENT_NEW,
4141
self::FORUM_TOPIC_REPLY,
42-
Notification::USER_ACHIEVEMENT_UNLOCK,
4342
];
4443

4544
const SUPPORTS_NOTIFICATIONS = [

Diff for: ‎app/Transformers/Multiplayer/UserScoreAggregateTransformer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function transform(UserScoreAggregate $score)
2323
'accuracy' => $score->averageAccuracy(),
2424
'attempts' => $score->attempts,
2525
'completed' => $score->completed,
26-
'pp' => $score->averagePp(),
26+
'pp' => 0,
2727
'room_id' => $score->room_id,
2828
'total_score' => $score->total_score,
2929
'user_id' => $score->user_id,

Diff for: ‎database/factories/BanchoStatsFactory.php

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public function definition(): array
1919
return [
2020
'users_irc' => fn() => 100 + $this->faker->randomNumber(2),
2121
'users_osu' => fn() => 10000 + $this->faker->randomNumber(4),
22+
'users_lazer' => fn() => 1000 + $this->faker->randomNumber(3),
2223
'multiplayer_games' => fn() => 200 + $this->faker->randomNumber(3),
2324
'date' => fn() => Carbon::now(),
2425
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
4+
// See the LICENCE file in the repository root for full licence text.
5+
6+
declare(strict_types=1);
7+
8+
use Illuminate\Database\Migrations\Migration;
9+
use Illuminate\Database\Schema\Blueprint;
10+
use Illuminate\Support\Facades\Schema;
11+
12+
return new class extends Migration
13+
{
14+
public function up(): void
15+
{
16+
Schema::table('osu_banchostats', function (Blueprint $table) {
17+
$table->smallInteger('users_irc')->default(0)->change();
18+
$table->mediumInteger('users_osu')->default(0)->change();
19+
$table->unsignedMediumInteger('users_lazer')->default(0)->change();
20+
$table->smallInteger('multiplayer_games')->default(0)->change();
21+
});
22+
}
23+
24+
public function down(): void
25+
{
26+
Schema::table('osu_banchostats', function (Blueprint $table) {
27+
$table->smallInteger('users_irc')->change();
28+
$table->mediumInteger('users_osu')->change();
29+
$table->unsignedMediumInteger('users_lazer')->change();
30+
$table->smallInteger('multiplayer_games')->change();
31+
});
32+
}
33+
};

Diff for: ‎resources/js/core/wiki/reference-link-tooltip.ts

+11-5
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,9 @@ export default class ReferenceLinkTooltip {
4444

4545
if (targetId == null) return;
4646

47-
const footnoteContent = document.querySelector(targetId)?.firstElementChild;
47+
const tooltipContent = document.querySelector(targetId)?.firstElementChild?.cloneNode(true);
4848

49-
if (!(footnoteContent instanceof HTMLParagraphElement)) return;
50-
51-
const tooltipContent = document.createElement('div');
52-
tooltipContent.insertAdjacentHTML('afterbegin', footnoteContent.innerHTML);
49+
if (!(tooltipContent instanceof HTMLParagraphElement)) return;
5350

5451
tooltipContent.querySelectorAll('*').forEach((node) => {
5552
if (node.getAttribute('role') === 'doc-backlink') {
@@ -58,6 +55,15 @@ export default class ReferenceLinkTooltip {
5855
node.removeAttribute('class');
5956
}
6057
});
58+
// Remove extra non-breaking spaces between backlink elements
59+
for (let i = tooltipContent.childNodes.length - 1; i >= 0; i--) {
60+
const node = tooltipContent.childNodes[i];
61+
if (node.textContent === ' ') {
62+
node.remove();
63+
} else {
64+
break;
65+
}
66+
}
6167

6268
this.createTooltip(el, tooltipContent);
6369
};

Diff for: ‎resources/js/scores-show/player.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default function Player(props: Props) {
1717
let title: string;
1818
let content: React.ReactNode;
1919

20-
if (props.score.rank_global == null || props.score.ranked === false || props.score.preserve === false) {
20+
if (props.score.rank_global == null || props.score.rank_global === 0 || props.score.ranked === false || props.score.preserve === false) {
2121
title = trans('scores.status.no_rank');
2222
content = '-';
2323
} else {

Diff for: ‎resources/js/turbolinks-overrides.coffee

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# See the LICENCE file in the repository root for full licence text.
33

44
import { currentUrl } from 'utils/turbolinks'
5-
import { isHTML, isInternal } from 'utils/url'
5+
import { isHTML } from 'utils/url'
66

77
# Anchor navigation with turbolinks. Works around [1].
88
# [1] https://github.com/turbolinks/turbolinks/issues/75
@@ -61,4 +61,7 @@ Turbolinks.Controller::replaceHistory = (url) ->
6161
Turbolinks.Snapshot::hasAnchor = -> true
6262

6363
Turbolinks.Controller::locationIsVisitable = (location) ->
64-
location.isPrefixedBy(@view.getRootLocation()) && isInternal(location) && isHTML(location)
64+
location.isPrefixedBy(@view.getRootLocation()) &&
65+
# old website pages
66+
!location.getPath().startsWith('/p/') &&
67+
isHTML(location)

Diff for: ‎resources/js/utils/legacy-score-helper.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ document.addEventListener('turbolinks:load', () => {
1616
});
1717

1818
function shouldHaveHiddenRank(score: SoloScoreJson) {
19-
return score.mods.some((mod) => mod.acronym === 'FL' || mod.acronym === 'HD');
19+
return score.mods.some((mod) => mod.acronym === 'FI' || mod.acronym === 'FL' || mod.acronym === 'HD');
2020
}
2121

2222
export function legacyAccuracyAndRank(score: SoloScoreJson) {

0 commit comments

Comments
 (0)