From 27c561623c16f8aa3ebd2a57b335dadd6874a2dc Mon Sep 17 00:00:00 2001 From: wzh425 Date: Fri, 9 Jan 2026 14:12:34 +0800 Subject: [PATCH] refactor: Improve filter case sensitivity in query handlers Updated the filtering logic in AlarmHistoryQueryHandler, AlarmRuleQueryHandler, and WebHookQueryHandler to perform case-insensitive searches by converting both the filter and the target display names to lowercase. This enhancement ensures more accurate search results regardless of the case used in the input. --- .../AlarmHistories/Queries/AlarmHistoryQueryHandler.cs | 4 ++-- .../AlarmRules/Queries/AlarmRuleQueryHandler.cs | 4 ++-- .../WebHooks/Queries/WebHookQueryHandler.cs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Application/Masa.Alert.Application/AlarmHistories/Queries/AlarmHistoryQueryHandler.cs b/src/Application/Masa.Alert.Application/AlarmHistories/Queries/AlarmHistoryQueryHandler.cs index 6c820d77..874c38b6 100644 --- a/src/Application/Masa.Alert.Application/AlarmHistories/Queries/AlarmHistoryQueryHandler.cs +++ b/src/Application/Masa.Alert.Application/AlarmHistories/Queries/AlarmHistoryQueryHandler.cs @@ -1,4 +1,4 @@ -// Copyright (c) MASA Stack All rights reserved. +// Copyright (c) MASA Stack All rights reserved. // Licensed under the Apache License. See LICENSE.txt in the project root for license information. namespace Masa.Alert.Application.AlarmHistories.Queries; @@ -55,7 +55,7 @@ public async Task GetListAsync(GetAlarmHistoryListQuery query) private async Task>> CreateFilteredPredicate(GetAlarmHistoryInputDto options) { Expression> condition = x => true; - condition = condition.And(!string.IsNullOrEmpty(options.Filter), x => x.AlarmRule.DisplayName.Contains(options.Filter)); + condition = condition.And(!string.IsNullOrEmpty(options.Filter), x => x.AlarmRule.DisplayName.ToLower().Contains(options.Filter.ToLower())); switch (options.SearchType) { case AlarmHistorySearchTypes.Alarming: diff --git a/src/Application/Masa.Alert.Application/AlarmRules/Queries/AlarmRuleQueryHandler.cs b/src/Application/Masa.Alert.Application/AlarmRules/Queries/AlarmRuleQueryHandler.cs index 5e51d6cd..640ef32e 100644 --- a/src/Application/Masa.Alert.Application/AlarmRules/Queries/AlarmRuleQueryHandler.cs +++ b/src/Application/Masa.Alert.Application/AlarmRules/Queries/AlarmRuleQueryHandler.cs @@ -1,4 +1,4 @@ -// Copyright (c) MASA Stack All rights reserved. +// Copyright (c) MASA Stack All rights reserved. // Licensed under the Apache License. See LICENSE.txt in the project root for license information. namespace Masa.Alert.Application.AlarmRules.Queries; @@ -54,7 +54,7 @@ public async Task GetListAsync(GetAlarmRuleListQuery query) private async Task>> CreateFilteredPredicate(GetAlarmRuleInputDto options) { Expression> condition = x => true; - condition = condition.And(!string.IsNullOrEmpty(options.Filter), x => x.DisplayName.Contains(options.Filter)); + condition = condition.And(!string.IsNullOrEmpty(options.Filter), x => x.DisplayName.ToLower().Contains(options.Filter.ToLower())); condition = condition.And(options.Type != default, x => x.Type == options.Type); condition = condition.And(x => x.Show == options.Show); if (options.TimeType == AlarmRuleSearchTimeTypes.ModificationTime) diff --git a/src/Application/Masa.Alert.Application/WebHooks/Queries/WebHookQueryHandler.cs b/src/Application/Masa.Alert.Application/WebHooks/Queries/WebHookQueryHandler.cs index 924ac93c..10a818a2 100644 --- a/src/Application/Masa.Alert.Application/WebHooks/Queries/WebHookQueryHandler.cs +++ b/src/Application/Masa.Alert.Application/WebHooks/Queries/WebHookQueryHandler.cs @@ -1,4 +1,4 @@ -// Copyright (c) MASA Stack All rights reserved. +// Copyright (c) MASA Stack All rights reserved. // Licensed under the Apache License. See LICENSE.txt in the project root for license information. namespace Masa.Alert.Application.WebHooks.Queries; @@ -48,7 +48,7 @@ public async Task GetListAsync(GetWebHookListQuery query) private async Task>> CreateFilteredPredicate(GetWebHookInputDto options) { Expression> condition = x => true; - condition = condition.And(!string.IsNullOrEmpty(options.Filter), x => x.DisplayName.Contains(options.Filter)); + condition = condition.And(!string.IsNullOrEmpty(options.Filter), x => x.DisplayName.ToLower().Contains(options.Filter.ToLower())); return await Task.FromResult(condition); ; }