Add missing source query filter in song select

This commit is contained in:
Joseph Madamba 2024-11-15 22:52:43 -08:00
parent 7c94973d4a
commit 465cc716d3
No known key found for this signature in database
GPG Key ID: 8B746C7BDDF0BD76
4 changed files with 7 additions and 0 deletions

View File

@ -509,6 +509,8 @@ public void TestApplySourceQueries()
FilterQueryParser.ApplyQueries(filterCriteria, query);
Assert.AreEqual("find me songs with please", filterCriteria.SearchText.Trim());
Assert.AreEqual(5, filterCriteria.SearchTerms.Length);
Assert.AreEqual("unit tests", filterCriteria.Source.SearchTerm);
Assert.That(filterCriteria.Source.MatchMode, Is.EqualTo(FilterCriteria.MatchMode.IsolatedPhrase));
}
private class CustomFilterCriteria : IRulesetFilterCriteria

View File

@ -81,6 +81,7 @@ private bool checkMatch(FilterCriteria criteria)
match &= !criteria.Title.HasFilter || criteria.Title.Matches(BeatmapInfo.Metadata.Title) ||
criteria.Title.Matches(BeatmapInfo.Metadata.TitleUnicode);
match &= !criteria.DifficultyName.HasFilter || criteria.DifficultyName.Matches(BeatmapInfo.DifficultyName);
match &= !criteria.Source.HasFilter || criteria.Source.Matches(BeatmapInfo.Metadata.Source);
match &= !criteria.UserStarDifficulty.HasFilter || criteria.UserStarDifficulty.IsInRange(BeatmapInfo.StarRating);
if (!match) return false;

View File

@ -43,6 +43,7 @@ public class FilterCriteria
public OptionalTextFilter Artist;
public OptionalTextFilter Title;
public OptionalTextFilter DifficultyName;
public OptionalTextFilter Source;
public OptionalRange<double> UserStarDifficulty = new OptionalRange<double>
{

View File

@ -113,6 +113,9 @@ private static bool tryParseKeywordCriteria(FilterCriteria criteria, string key,
case "diff":
return TryUpdateCriteriaText(ref criteria.DifficultyName, op, value);
case "source":
return TryUpdateCriteriaText(ref criteria.Source, op, value);
default:
return criteria.RulesetCriteria?.TryParseCustomKeywordCriteria(key, op, value) ?? false;
}