Skip to content

Commit 8268b7d

Browse files
authored
Merge pull request #11003 from nanaya/score-pin-id
Record new score id when pinning
2 parents 28bfe59 + 0e706c9 commit 8268b7d

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

app/Http/Controllers/ScorePinsController.php

+9-2
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,16 @@ public function store()
9191
$rulesetId = Beatmap::MODES[$score->getMode()];
9292
$currentMinDisplayOrder = $user->scorePins()->where('ruleset_id', $rulesetId)->min('display_order') ?? 2500;
9393

94+
$soloScore = $score instanceof Solo\Score
95+
? $score
96+
: Solo\Score::firstWhere(['ruleset_id' => $rulesetId, 'legacy_score_id' => $score->getKey()]);
97+
9498
try {
95-
(new ScorePin(['display_order' => $currentMinDisplayOrder - 100, 'ruleset_id' => $rulesetId]))
96-
->user()->associate($user)
99+
(new ScorePin([
100+
'display_order' => $currentMinDisplayOrder - 100,
101+
'ruleset_id' => $rulesetId,
102+
'new_score_id' => $soloScore?->getKey(),
103+
]))->user()->associate($user)
97104
->score()->associate($score)
98105
->saveOrExplode();
99106
} catch (Exception $ex) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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('score_pins', function (Blueprint $table) {
17+
$table->unsignedBigInteger('new_score_id')->after('score_id')->nullable(true);
18+
});
19+
}
20+
21+
public function down(): void
22+
{
23+
Schema::table('score_pins', function (Blueprint $table) {
24+
$table->dropColumn('new_score_id');
25+
});
26+
}
27+
};

0 commit comments

Comments
 (0)