Skip to content

Commit 27c5616

Browse files
committed
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.
1 parent 176f47e commit 27c5616

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/Application/Masa.Alert.Application/AlarmHistories/Queries/AlarmHistoryQueryHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) MASA Stack All rights reserved.
1+
// Copyright (c) MASA Stack All rights reserved.
22
// Licensed under the Apache License. See LICENSE.txt in the project root for license information.
33

44
namespace Masa.Alert.Application.AlarmHistories.Queries;
@@ -55,7 +55,7 @@ public async Task GetListAsync(GetAlarmHistoryListQuery query)
5555
private async Task<Expression<Func<AlarmHistoryQueryModel, bool>>> CreateFilteredPredicate(GetAlarmHistoryInputDto options)
5656
{
5757
Expression<Func<AlarmHistoryQueryModel, bool>> condition = x => true;
58-
condition = condition.And(!string.IsNullOrEmpty(options.Filter), x => x.AlarmRule.DisplayName.Contains(options.Filter));
58+
condition = condition.And(!string.IsNullOrEmpty(options.Filter), x => x.AlarmRule.DisplayName.ToLower().Contains(options.Filter.ToLower()));
5959
switch (options.SearchType)
6060
{
6161
case AlarmHistorySearchTypes.Alarming:

src/Application/Masa.Alert.Application/AlarmRules/Queries/AlarmRuleQueryHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) MASA Stack All rights reserved.
1+
// Copyright (c) MASA Stack All rights reserved.
22
// Licensed under the Apache License. See LICENSE.txt in the project root for license information.
33

44
namespace Masa.Alert.Application.AlarmRules.Queries;
@@ -54,7 +54,7 @@ public async Task GetListAsync(GetAlarmRuleListQuery query)
5454
private async Task<Expression<Func<AlarmRuleQueryModel, bool>>> CreateFilteredPredicate(GetAlarmRuleInputDto options)
5555
{
5656
Expression<Func<AlarmRuleQueryModel, bool>> condition = x => true;
57-
condition = condition.And(!string.IsNullOrEmpty(options.Filter), x => x.DisplayName.Contains(options.Filter));
57+
condition = condition.And(!string.IsNullOrEmpty(options.Filter), x => x.DisplayName.ToLower().Contains(options.Filter.ToLower()));
5858
condition = condition.And(options.Type != default, x => x.Type == options.Type);
5959
condition = condition.And(x => x.Show == options.Show);
6060
if (options.TimeType == AlarmRuleSearchTimeTypes.ModificationTime)

src/Application/Masa.Alert.Application/WebHooks/Queries/WebHookQueryHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) MASA Stack All rights reserved.
1+
// Copyright (c) MASA Stack All rights reserved.
22
// Licensed under the Apache License. See LICENSE.txt in the project root for license information.
33

44
namespace Masa.Alert.Application.WebHooks.Queries;
@@ -48,7 +48,7 @@ public async Task GetListAsync(GetWebHookListQuery query)
4848
private async Task<Expression<Func<WebHookQueryModel, bool>>> CreateFilteredPredicate(GetWebHookInputDto options)
4949
{
5050
Expression<Func<WebHookQueryModel, bool>> condition = x => true;
51-
condition = condition.And(!string.IsNullOrEmpty(options.Filter), x => x.DisplayName.Contains(options.Filter));
51+
condition = condition.And(!string.IsNullOrEmpty(options.Filter), x => x.DisplayName.ToLower().Contains(options.Filter.ToLower()));
5252
return await Task.FromResult(condition); ;
5353
}
5454

0 commit comments

Comments
 (0)