Skip to content

Commit

Permalink
Merge branch 'master' into docs-nav-button
Browse files Browse the repository at this point in the history
  • Loading branch information
notbakaneko authored Jan 28, 2025
2 parents 212bfc4 + d470f0c commit a60065f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
5 changes: 3 additions & 2 deletions app/Http/Controllers/BeatmapsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
class BeatmapsController extends Controller
{
const DEFAULT_API_INCLUDES = ['beatmapset.ratings', 'failtimes', 'max_combo'];
const DEFAULT_API_INCLUDES = ['beatmapset.ratings', 'failtimes', 'max_combo', 'owners'];
const DEFAULT_SCORE_INCLUDES = ['user', 'user.country', 'user.cover', 'user.team'];

public function __construct()
Expand Down Expand Up @@ -194,7 +194,7 @@ public function attributes($id)
*
* Field | Type | Description
* -------- | ------------------------------------- | -----------
* beatmaps | [BeatmapExtended](#beatmapextended)[] | Includes `beatmapset` (with `ratings`), `failtimes`, and `max_combo`.
* beatmaps | [BeatmapExtended](#beatmapextended)[] | Includes `beatmapset` (with `ratings`), `failtimes`, `max_combo`, and `owners`.
*
* @queryParam ids[] integer Beatmap IDs to be returned. Specify once for each beatmap ID requested. Up to 50 beatmaps can be requested at once. Example: 1
*
Expand All @@ -216,6 +216,7 @@ public function index()
::whereIn('beatmap_id', $ids)
->whereHas('beatmapset')
->with([
'beatmapOwners.user',
'beatmapset',
'beatmapset.userRatings' => fn ($q) => $q->select('beatmapset_id', 'rating'),
'failtimes',
Expand Down
12 changes: 11 additions & 1 deletion app/Models/Contest.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,24 @@ public function entriesByType($user = null, array $preloads = [])
// Only return contest entries that a user has actually played
return $entries
->whereIn('entry_url', function ($query) use ($user) {
$options = $this->getExtraOptions()['best_of'];
$ruleset = $options['mode'] ?? 'osu';
$query->select('beatmapset_id')
->from('osu_beatmaps')
->where('osu_beatmaps.playmode', Beatmap::MODES[$this->getExtraOptions()['best_of']['mode'] ?? 'osu'])
->where('osu_beatmaps.playmode', Beatmap::MODES[$ruleset])
->whereIn('beatmap_id', function ($query) use ($user) {
$query->select('beatmap_id')
->from('osu_user_beatmap_playcount')
->where('user_id', '=', $user->user_id);
});

if ($ruleset === 'mania' && isset($options['variant'])) {
$keys = match ($options['variant']) {
'4k' => 4,
'7k' => 7,
};
$query->where('osu_beatmaps.diff_size', $keys);
}
})->get();
}
}
Expand Down
1 change: 1 addition & 0 deletions resources/views/docs/_structures/beatmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ beatmapset | [Beatmapset](#beatmapset)\|[BeatmapsetExtended](#beatmapsetextende
checksum | string? | |
failtimes | [Failtimes](#beatmap-failtimes) | |
max_combo | integer | |
owners | [BeatmapOwner](#beatmapowner)[] | List of owners (mappers) for the Beatmap.

<div id="beatmap-failtimes" data-unique="beatmap-failtimes"></div>

Expand Down
8 changes: 8 additions & 0 deletions resources/views/docs/_structures/beatmap_owner.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## BeatmapOwner

Field | Type | Description
-------- | ------- | ------------
id | integer | [User](#user) id of the Beatmap owner.
username | string | Username of the Beatmap owner.

Users that are no longer visible will still appear as a `BeatmapOwner` but have the `username` set to `[deleted user]`.

0 comments on commit a60065f

Please sign in to comment.