Skip to content

Commit 027a872

Browse files
authored
Merge pull request #12047 from notbakaneko/feature/tag-search-quote
Use fully quoted tags for Beatmapset user tag links
2 parents bb3bd2e + da13d96 commit 027a872

File tree

4 files changed

+23
-14
lines changed

4 files changed

+23
-14
lines changed

app/Libraries/Search/BeatmapsetSearch.php

+16-7
Original file line numberDiff line numberDiff line change
@@ -408,20 +408,29 @@ private function addTextFilter(BoolQuery $query, string $paramField, array $fiel
408408

409409
private function addTagsFilter(BoolQuery $query): void
410410
{
411-
if ($this->params->tags === null) {
411+
$tags = $this->params->tags;
412+
if ($tags === null) {
412413
return;
413414
}
414415

415-
$tagSet = new Set(array_map('mb_strtolower', $this->params->tags));
416-
$tags = Tag::whereIn('name', $this->params->tags)->limit(10)->pluck('name');
417-
$tagSet->remove(...$tags->map(fn ($name) => mb_strtolower($name))->toArray());
416+
// workaround multi tag parsing when there's an empty tag.
417+
$tags = array_reject_null($tags);
418418

419-
foreach ($tagSet as $tag) {
420-
$query->filter(QueryHelper::queryString($tag, ['beatmaps.top_tags'], 'and'));
419+
$tagMap = [];
420+
foreach ($tags as $tag) {
421+
$key = mb_strtolower(mb_trim($tag, '"'));
422+
$tagMap[$key] = $tag;
421423
}
422424

423-
foreach ($tags as $tag) {
425+
$exactTags = Tag::whereIn('name', array_keys($tagMap))->limit(10)->pluck('name');
426+
427+
foreach ($exactTags as $tag) {
424428
$query->filter(['term' => ['beatmaps.top_tags.raw' => $tag]]);
429+
unset($tagMap[mb_strtolower($tag)]);
430+
}
431+
432+
foreach (array_values($tagMap) as $tag) {
433+
$query->filter(QueryHelper::queryString($tag, ['beatmaps.top_tags'], 'and'));
425434
}
426435
}
427436

resources/js/beatmapsets-show/info.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,11 @@ export default class Info extends React.Component<Props> {
194194
{trans('beatmapsets.show.info.user_tags')}
195195
</h3>
196196
<div className='beatmapset-info__value-overflow'>
197-
{this.controller.tags.userTags.map((tag, i) => (
198-
<React.Fragment key={`${tag.name}-${i}`}>
197+
{this.controller.tags.userTags.map((tag) => (
198+
<React.Fragment key={tag.name}>
199199
<a
200200
className='beatmapset-info__link'
201-
href={route('beatmapsets.index', { q: tag.name })}
201+
href={route('beatmapsets.index', { q: makeSearchQueryOption('tag', tag.name) })}
202202
>
203203
{tag.name}
204204
</a>

resources/js/contest-judge-results/header.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ export default class Header extends React.PureComponent<Props> {
4141
<div className='contest-judge-results-header__values'>
4242
<ValueDisplay
4343
label={trans('contest.judge_results.total_score')}
44-
modifiers={'judge-results'}
44+
modifiers='judge-results'
4545
value={totalScore}
4646
/>
4747

4848
<ValueDisplay
4949
label={trans('contest.judge_results.creator')}
50-
modifiers={'judge-results'}
50+
modifiers='judge-results'
5151
value={
5252
<UserLink user={this.props.entry.user} />
5353
}

resources/lang/en/beatmapsets.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
'description' => 'Description',
141141
'genre' => 'Genre',
142142
'language' => 'Language',
143+
'mapper_tags' => 'Mapper Tags',
143144
'no_scores' => 'Data still being calculated...',
144145
'nominators' => 'Nominators',
145146
'nsfw' => 'Explicit content',
@@ -148,9 +149,8 @@
148149
'source' => 'Source',
149150
'storyboard' => 'This beatmap contains storyboard',
150151
'success-rate' => 'Success Rate',
151-
'video' => 'This beatmap contains video',
152152
'user_tags' => 'User Tags',
153-
'mapper_tags' => 'Mapper Tags',
153+
'video' => 'This beatmap contains video',
154154
],
155155

156156
'nsfw_warning' => [

0 commit comments

Comments
 (0)