Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add beatmapset difficulty name search filter #10534

Merged
merged 3 commits into from
Sep 8, 2023
Merged
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: 3 additions & 0 deletions app/Libraries/Search/BeatmapsetQueryParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public static function parse(?string $query): array
case 'creator':
$option = static::makeTextOption($op, $m['value']);
break;
case 'difficulty':
$option = static::makeTextOption($op, $m['value']);
break;
case 'artist':
$option = static::makeTextOption($op, $m['value']);
break;
Expand Down
8 changes: 8 additions & 0 deletions app/Libraries/Search/BeatmapsetSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public function getQuery()
$this->addSpotlightsFilter($query);

$nested = new BoolQuery();
$this->addDifficultyFilter($nested);
$this->addStatusFilter($query, $nested);
$this->addManiaKeysFilter($nested);
$this->addModeFilter($nested);
Expand Down Expand Up @@ -166,6 +167,13 @@ private function addCreatorFilter(BoolQuery $query, BoolQuery $nested): void
}
}

private function addDifficultyFilter(BoolQuery $nested)
{
if ($this->params->difficulty !== null) {
$nested->must(QueryHelper::queryString($this->params->difficulty, ['beatmaps.version'], 'and'));
}
}

private function addExtraFilter($query)
{
foreach ($this->params->extra as $val) {
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 @@ -21,6 +21,7 @@ class BeatmapsetSearchParams extends SearchParams
public ?array $created = null;
public ?string $creator = null;
public ?array $cs = null;
public ?string $difficulty = null;
public ?array $difficultyRating = null;
public ?array $drain = null;
public array $extra = [];
Expand Down
1 change: 1 addition & 0 deletions app/Libraries/Search/BeatmapsetSearchRequestParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ private function parseQuery(): void
'created' => 'created',
'creator' => 'creator',
'cs' => 'cs',
'difficulty' => 'difficulty',
'dr' => 'drain',
'featured_artist' => 'featuredArtist',
'keys' => 'keys',
Expand Down