Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions app/Http/Controllers/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public function extraPages($_id, $page)
'replays_watched_counts' => json_collection($this->user->replaysWatchedCounts, new UserReplaysWatchedCountTransformer()),
'score_replay_stats' => $this->getExtraSection(
'scoreReplayStats',
$this->user->scoreReplayStats()->whereHas('score.beatmap')->countLimit($this->maxResults),
$this->user->scoreReplayStats()->countLimit($this->maxResults),
),
];

Expand Down Expand Up @@ -853,7 +853,6 @@ private function getExtra($page, array $options, int $perPage = 10, int $offset
$transformer = new ScoreReplayStatsTransformer();
$includes = ScoreReplayStatsTransformer::USER_PROFILE_INCLUDES;
$query = $this->user->scoreReplayStats()
->whereHas('score.beatmap')
->orderByDesc('watch_count')
->with(ScoreReplayStatsTransformer::USER_PROFILE_INCLUDES_PRELOAD);
break;
Expand Down
4 changes: 3 additions & 1 deletion app/Transformers/ScoreReplayStatsTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public function transform(ScoreReplayStats $stats): array

public function includeScore(ScoreReplayStats $stats): ResourceInterface
{
return $this->item($stats->score, new ScoreTransformer());
return $stats->score !== null
? $this->item($stats->score, new ScoreTransformer())
: $this->null();
}
}
4 changes: 2 additions & 2 deletions resources/js/interfaces/score-replay-stats-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import ScoreJson, { ScoreJsonForUser } from './score-json';

interface ScoreReplayStatsJsonAvailableIncludes {
score: ScoreJson;
score: ScoreJson|null;
}

interface ScoreReplayStatsJsonDefaultAttributes {
Expand All @@ -16,4 +16,4 @@ type ScoreReplayStatsJson = ScoreReplayStatsJsonDefaultAttributes & Partial<Scor

export default ScoreReplayStatsJson;

export type ScoreReplayStatsJsonForUser = ScoreReplayStatsJson & { score: ScoreJsonForUser };
export type ScoreReplayStatsJsonForUser = ScoreReplayStatsJson & { score: ScoreJsonForUser|null };
4 changes: 4 additions & 0 deletions resources/js/profile-page/score-replay-stats-entry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export default function ScoreReplayStatsEntry(props: Props) {
const user = props.user;
const stats = props.stats;
const score = stats.score;
if (score == null) {
return null;
}

const scoreRank = rank(score);
const { beatmap, beatmapset } = score;

Expand Down