From f799829e561a32d5078a2ba1eac881a44ce6b6a0 Mon Sep 17 00:00:00 2001 From: patriot720 Date: Thu, 9 Jan 2025 17:43:30 +0300 Subject: [PATCH] add ability to search by circle or slider count --- app/Libraries/Search/BeatmapsetQueryParser.php | 6 ++++++ app/Libraries/Search/BeatmapsetSearch.php | 2 ++ app/Libraries/Search/BeatmapsetSearchParams.php | 2 ++ app/Libraries/Search/BeatmapsetSearchRequestParams.php | 2 ++ 4 files changed, 12 insertions(+) diff --git a/app/Libraries/Search/BeatmapsetQueryParser.php b/app/Libraries/Search/BeatmapsetQueryParser.php index faa4f51b8cd..24d3e16b040 100644 --- a/app/Libraries/Search/BeatmapsetQueryParser.php +++ b/app/Libraries/Search/BeatmapsetQueryParser.php @@ -41,6 +41,12 @@ public static function parse(?string $query): array case 'bpm': $option = static::makeFloatRangeOption($op, $m['value'], 0.01 / 2); break; + case 'circles': + $option = static::makeIntRangeOption($op, $m['value']); + break; + case 'sliders': + $option = static::makeIntRangeOption($op, $m['value']); + break; case 'length': $parsed = get_length_seconds($m['value']); if ($parsed !== null) { diff --git a/app/Libraries/Search/BeatmapsetSearch.php b/app/Libraries/Search/BeatmapsetSearch.php index f88edc7f930..96857e5777f 100644 --- a/app/Libraries/Search/BeatmapsetSearch.php +++ b/app/Libraries/Search/BeatmapsetSearch.php @@ -307,6 +307,8 @@ private function addSimpleFilters(BoolQuery $query, BoolQuery $nested): void 'accuracy' => ['field' => 'beatmaps.diff_overall', 'type' => 'range'], 'ar' => ['field' => 'beatmaps.diff_approach', 'type' => 'range'], 'bpm' => ['field' => 'bpm', 'type' => 'range'], + 'countNormal' => ['field' => 'beatmaps.countNormal', 'type' => 'range'], + 'countSlider' => ['field' => 'beatmaps.countSlider', 'type' => 'range'], 'created' => ['field' => 'submit_date', 'type' => 'range'], 'cs' => ['field' => 'beatmaps.diff_size', 'type' => 'range'], 'difficultyRating' => ['field' => 'beatmaps.difficultyrating', 'type' => 'range'], diff --git a/app/Libraries/Search/BeatmapsetSearchParams.php b/app/Libraries/Search/BeatmapsetSearchParams.php index 9cbd9b9e0d9..03cce272fbd 100644 --- a/app/Libraries/Search/BeatmapsetSearchParams.php +++ b/app/Libraries/Search/BeatmapsetSearchParams.php @@ -19,6 +19,8 @@ class BeatmapsetSearchParams extends SearchParams public ?array $ar = null; public ?string $artist = null; public ?array $bpm = null; + public ?array $countNormal = null; + public ?array $countSlider = null; public ?array $created = null; public ?string $creator = null; public ?array $cs = null; diff --git a/app/Libraries/Search/BeatmapsetSearchRequestParams.php b/app/Libraries/Search/BeatmapsetSearchRequestParams.php index c070c61139e..21d46a94193 100644 --- a/app/Libraries/Search/BeatmapsetSearchRequestParams.php +++ b/app/Libraries/Search/BeatmapsetSearchRequestParams.php @@ -213,6 +213,7 @@ private function parseQuery(): void 'created' => 'created', 'creator' => 'creator', 'cs' => 'cs', + 'circles' => 'countNormal', 'difficulty' => 'difficulty', 'dr' => 'drain', 'favourites' => 'favouriteCount', @@ -224,6 +225,7 @@ private function parseQuery(): void 'source' => 'source', 'stars' => 'difficultyRating', 'status' => 'statusRange', + 'sliders' => 'countSlider', 'title' => 'title', 'updated' => 'updated', ];