Skip to content
Open
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
9 changes: 9 additions & 0 deletions app/Libraries/Search/BeatmapsetSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function getQuery()
$this->addFeaturedArtistFilter($query);
$this->addFeaturedArtistsFilter($query);
$this->addFollowsFilter($query);
$this->addExclusiveTracksFilter($query);
$this->addGenreFilter($query);
$this->addLanguageFilter($query);
$this->addExtraFilter($query);
Expand Down Expand Up @@ -174,6 +175,14 @@ private function addFeaturedArtistsFilter($query)
}
}

private function addExclusiveTracksFilter($query)
{
if ($this->params->showExclusiveTracks) {
$trackIds = ArtistTrack::where('exclusive', true)->pluck('id');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add another field to the es index instead of passing hundreds of id every time

$query->filter(['terms' => ['track_id' => $trackIds]]);
}
}

private function addFollowsFilter($query)
{
if ($this->params->showFollows && $this->params->user !== null) {
Expand Down
1 change: 1 addition & 0 deletions app/Libraries/Search/BeatmapsetSearchParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class BeatmapsetSearchParams extends SearchParams
public ?array $ranked = null;
public bool $showFeaturedArtists = false;
public bool $showFollows = false;
public bool $showExclusiveTracks = false;
public bool $showRecommended = false;
public bool $showSpotlights = false;
public ?string $source = null;
Expand Down
3 changes: 2 additions & 1 deletion app/Libraries/Search/BeatmapsetSearchRequestParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class BeatmapsetSearchRequestParams extends BeatmapsetSearchParams
{
const AVAILABLE_STATUSES = ['any', 'leaderboard', 'ranked', 'qualified', 'loved', 'favourites', 'pending', 'wip', 'graveyard', 'mine'];
const AVAILABLE_EXTRAS = ['video', 'storyboard'];
const AVAILABLE_GENERAL = ['recommended', 'converts', 'follows', 'spotlights', 'featured_artists'];
const AVAILABLE_GENERAL = ['recommended', 'converts', 'follows', 'spotlights', 'featured_artists', 'osu_originals'];
const AVAILABLE_PLAYED = ['any', 'played', 'unplayed'];
const AVAILABLE_RANKS = ['XH', 'X', 'SH', 'S', 'A', 'B', 'C', 'D'];

Expand Down Expand Up @@ -105,6 +105,7 @@ public function __construct(array $request, ?User $user = null)
$this->includeConverts = in_array('converts', $generals, true);
$this->showFeaturedArtists = in_array('featured_artists', $generals, true);
$this->showFollows = in_array('follows', $generals, true);
$this->showExclusiveTracks = in_array('osu_originals', $generals, true);
$this->showRecommended = in_array('recommended', $generals, true);
$this->showSpotlights = in_array('spotlights', $generals, true);

Expand Down
1 change: 1 addition & 0 deletions app/Transformers/BeatmapsetCompactTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public function transform(Beatmapset $beatmapset)
'title' => $beatmapset->title,
'title_unicode' => $beatmapset->title_unicode,
'track_id' => $beatmapset->track_id,
'is_exclusive_track' => $beatmapset->track?->exclusive ?? false,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this just can't be here as it'll cause one additional query for each beatmapset

'user_id' => $beatmapset->user_id,
'video' => $beatmapset->video,
];
Expand Down
6 changes: 6 additions & 0 deletions resources/css/bem/beatmapset-badge.less
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@
--colour-hover: hsl(var(--hsl-blue-1));
}

&--exclusive {
--colour: hsl(var(--hsl-pink-2));
--colour-hover: hsl(var(--hsl-pink-1));
}

&--nsfw {
--colour: hsl(var(--hsl-orange-2));
--colour-hover: hsl(var(--hsl-orange-1));
}

&--panel {
Expand Down
5 changes: 5 additions & 0 deletions resources/css/bem/beatmapsets-search-filter.less
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
--colour-hover: var(--colour);
}

&--osu-originals {
--colour: hsl(var(--hsl-pink-1));
--colour-hover: var(--colour);
}

&:focus {
color: var(--colour);
}
Expand Down
1 change: 1 addition & 0 deletions resources/js/beatmap-discussions/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export class Header extends React.Component<Props> {
<h2 className={`${bn}__title ${bn}__title--artist`}>
{getArtist(this.beatmapset)}
<BeatmapsetBadge beatmapset={this.beatmapset} type='featured_artist' />
<BeatmapsetBadge beatmapset={this.beatmapset} type='exclusive' />
</h2>
</div>
<div className={`${bn}__filters`}>
Expand Down
1 change: 1 addition & 0 deletions resources/js/beatmaps/search-filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export class SearchFilter extends React.Component<Props> {
const cssClasses = classWithModifiers('beatmapsets-search-filter__item', {
active: this.isSelected(option.id),
'featured-artists': option.id === 'featured_artists',
'osu-originals': option.id === 'osu_originals',
});

let text = option.name;
Expand Down
1 change: 1 addition & 0 deletions resources/js/beatmapset-panel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ export default class BeatmapsetPanel extends React.Component<Props> {
</a>
<div className="beatmapset-panel__badge-container">
<BeatmapsetBadge beatmapset={this.props.beatmapset} type='featured_artist' />
<BeatmapsetBadge beatmapset={this.props.beatmapset} type='exclusive' />
</div>
</div>

Expand Down
4 changes: 4 additions & 0 deletions resources/js/beatmapsets-show/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ export default class Header extends React.Component<Props> {
beatmapset={this.controller.beatmapset}
type='featured_artist'
/>
<BeatmapsetBadge
beatmapset={this.controller.beatmapset}
type='exclusive'
/>
</span>

<BeatmapsetMapping beatmapset={this.controller.beatmapset} />
Expand Down
11 changes: 9 additions & 2 deletions resources/js/components/beatmapset-badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,27 @@ import { wikiUrl } from 'utils/url';
interface Props {
beatmapset: BeatmapsetJson;
modifiers?: Modifiers;
type: 'featured_artist' | 'nsfw' | 'spotlight';
type: 'exclusive' | 'featured_artist' | 'nsfw' | 'spotlight';
}

export default function BeatmapsetBadge(props: Props) {
let url: string | undefined;

switch (props.type) {
case 'exclusive':
if ((props.beatmapset.track_id == null) || !props.beatmapset.is_exclusive_track) return null;

url = route('tracks.show', { track: props.beatmapset.track_id });
break;
case 'featured_artist':
if (props.beatmapset.track_id == null) return null;
if ((props.beatmapset.track_id == null) || props.beatmapset.is_exclusive_track) return null;

url = route('tracks.show', { track: props.beatmapset.track_id });
break;
case 'nsfw':
if (!props.beatmapset.nsfw) return null;

url = wikiUrl('Rules/Explicit_content');
break;
case 'spotlight':
if (!props.beatmapset.spotlight) return null;
Expand Down
2 changes: 2 additions & 0 deletions resources/js/interfaces/beatmapset-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ interface BeatmapsetJsonDefaultAttributes {
favourite_count: number;
hype: HypeData | null;
id: number;
is_exclusive_track: boolean;
nsfw: boolean;
offset: number;
play_count: number;
Expand Down Expand Up @@ -146,6 +147,7 @@ export function deletedBeatmapset(): BeatmapsetJson {
favourite_count: 0,
hype: null,
id: 0,
is_exclusive_track: false,
nsfw: false,
offset: 0,
play_count: 0,
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en/beatmaps.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@
'converts' => 'Include converted beatmaps',
'featured_artists' => 'Featured Artists',
'follows' => 'Subscribed mappers',
'osu_originals' => 'osu! originals',
'recommended' => 'Recommended difficulty',
'spotlights' => 'Spotlighted beatmaps',
],
Expand Down
4 changes: 4 additions & 0 deletions resources/lang/en/beatmapsets.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
'label' => 'Featured Artist',
],

'exclusive_badge' => [
'label' => 'osu! original',
],

'index' => [
'title' => 'Beatmaps Listing',
'guest_title' => 'Beatmaps',
Expand Down
1 change: 1 addition & 0 deletions resources/views/docs/_structures/beatmapset.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ recent_favourites |
related_users | | |
user | | |
track_id | integer | |
is_exclusive_track | boolean | |

<div id="beatmapset-covers" data-unique="beatmapset-covers"></div>

Expand Down