From fb4ab906f654a6d499ddb2894038f0f6a2e334f9 Mon Sep 17 00:00:00 2001 From: Rhys Bevilaqua Date: Tue, 28 Jul 2026 10:33:28 +0800 Subject: [PATCH] Remove unused search method --- .../When_a_message_has_failed.cs | 41 ------------- .../Implementation/QueueAddressStore.cs | 3 - .../QueueAddressStore.cs | 15 ----- .../IQueueAddressStore.cs | 1 - .../APIApprovals.HttpApiRoutes.approved.txt | 1 - .../Api/QueueAddressController.cs | 60 +++++++------------ 6 files changed, 21 insertions(+), 100 deletions(-) diff --git a/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_message_has_failed.cs b/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_message_has_failed.cs index fed08d7135..e8c7b26d56 100644 --- a/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_message_has_failed.cs +++ b/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_message_has_failed.cs @@ -240,47 +240,6 @@ await Define() Assert.That(searchResults.Count, Is.EqualTo(1), "Result count did not match"); } - [Test] - public async Task Should_only_return_queueaddresses_that_startswith_search() - { - var searchResults = new List(); - const string searchTerm = "another"; - const string searchEndpointName = "AnotherFailingEndpoint"; - - await Define() - .WithEndpoint(b => - { - b.DoNotFailOnErrorMessages(); - b.When(bus => bus.SendLocal(new MyMessage())); - }) - .WithEndpoint(b => - { - b.DoNotFailOnErrorMessages(); - b.CustomConfig(configuration => configuration.GetSettings().Set("NServiceBus.Routing.EndpointName", searchEndpointName)); - b.When(bus => bus.SendLocal(new MyMessage())); - }) - .WithEndpoint(b => - { - b.DoNotFailOnErrorMessages(); - b.CustomConfig(configuration => configuration.GetSettings().Set("NServiceBus.Routing.EndpointName", "YetAnotherEndpoint")); - b.When(bus => bus.SendLocal(new MyMessage())); - }).Done(async c => - { - if (c.FailedMessageCount < 3) - { - return false; - } - - var result = await this.TryGetMany($"/api/errors/queues/addresses/search/{searchTerm}"); - searchResults = result; - return result; - }) - .Run(); - - Assert.That(searchResults.Count, Is.EqualTo(1), "Result count did not match"); - Assert.That(searchResults[0].PhysicalAddress.StartsWith(searchEndpointName, StringComparison.InvariantCultureIgnoreCase), Is.True); - } - public class EndpointThatUsesSignalR : EndpointConfigurationBuilder { public EndpointThatUsesSignalR() => diff --git a/src/ServiceControl.Persistence.EFCore/Implementation/QueueAddressStore.cs b/src/ServiceControl.Persistence.EFCore/Implementation/QueueAddressStore.cs index b53673b630..a4ed0adeb3 100644 --- a/src/ServiceControl.Persistence.EFCore/Implementation/QueueAddressStore.cs +++ b/src/ServiceControl.Persistence.EFCore/Implementation/QueueAddressStore.cs @@ -7,7 +7,4 @@ public class QueueAddressStore : IQueueAddressStore { public Task>> GetAddresses(PagingInfo pagingInfo) => throw new NotImplementedException(); - - public Task>> GetAddressesBySearchTerm(string search, PagingInfo pagingInfo) => - throw new NotImplementedException(); } diff --git a/src/ServiceControl.Persistence.RavenDB/QueueAddressStore.cs b/src/ServiceControl.Persistence.RavenDB/QueueAddressStore.cs index 2120810aaf..0b4705fa44 100644 --- a/src/ServiceControl.Persistence.RavenDB/QueueAddressStore.cs +++ b/src/ServiceControl.Persistence.RavenDB/QueueAddressStore.cs @@ -22,20 +22,5 @@ public async Task>> GetAddresses(PagingInfo pagi var result = new QueryResult>(addresses, stats.ToQueryStatsInfo()); return result; } - - public async Task>> GetAddressesBySearchTerm(string search, PagingInfo pagingInfo) - { - using var session = await sessionProvider.OpenSession(); - var failedMessageQueues = await session - .Query() - .Statistics(out var stats) - .Paging(pagingInfo) - .Where(q => q.PhysicalAddress.StartsWith(search)) - .OrderBy(q => q.PhysicalAddress) - .ToListAsync(); - - var result = new QueryResult>(failedMessageQueues, stats.ToQueryStatsInfo()); - return result; - } } } \ No newline at end of file diff --git a/src/ServiceControl.Persistence/IQueueAddressStore.cs b/src/ServiceControl.Persistence/IQueueAddressStore.cs index c1f12cf6d1..07ab28618e 100644 --- a/src/ServiceControl.Persistence/IQueueAddressStore.cs +++ b/src/ServiceControl.Persistence/IQueueAddressStore.cs @@ -8,6 +8,5 @@ public interface IQueueAddressStore { Task>> GetAddresses(PagingInfo pagingInfo); - Task>> GetAddressesBySearchTerm(string search, PagingInfo pagingInfo); } } \ No newline at end of file diff --git a/src/ServiceControl.UnitTests/ApprovalFiles/APIApprovals.HttpApiRoutes.approved.txt b/src/ServiceControl.UnitTests/ApprovalFiles/APIApprovals.HttpApiRoutes.approved.txt index 5a0176d2f5..af9b1bfa9d 100644 --- a/src/ServiceControl.UnitTests/ApprovalFiles/APIApprovals.HttpApiRoutes.approved.txt +++ b/src/ServiceControl.UnitTests/ApprovalFiles/APIApprovals.HttpApiRoutes.approved.txt @@ -33,7 +33,6 @@ GET /errors/groups/{classifier?} => ServiceControl.MessageFailures.Api.ArchiveMe GET /errors/last/{failedMessageId:required:minlength(1)} => ServiceControl.MessageFailures.Api.GetErrorByIdController:ErrorLastBy(String failedMessageId) POST /errors/queues/{queueAddress:required:minlength(1)}/retry => ServiceControl.MessageFailures.Api.RetryMessagesController:RetryAllBy(String queueAddress) GET /errors/queues/addresses => ServiceControl.MessageFailures.Api.QueueAddressController:GetAddresses(PagingInfo pagingInfo) -GET /errors/queues/addresses/search/{search} => ServiceControl.MessageFailures.Api.QueueAddressController:GetAddressesBySearchTerm(PagingInfo pagingInfo, String search) POST /errors/retry => ServiceControl.MessageFailures.Api.RetryMessagesController:RetryAllBy(List messageIds) POST /errors/retry/all => ServiceControl.MessageFailures.Api.RetryMessagesController:RetryAll() GET /errors/summary => ServiceControl.MessageFailures.Api.GetAllErrorsController:ErrorsSummary() diff --git a/src/ServiceControl/MessageFailures/Api/QueueAddressController.cs b/src/ServiceControl/MessageFailures/Api/QueueAddressController.cs index 44e043426c..dc82dfe18a 100644 --- a/src/ServiceControl/MessageFailures/Api/QueueAddressController.cs +++ b/src/ServiceControl/MessageFailures/Api/QueueAddressController.cs @@ -1,45 +1,27 @@ -namespace ServiceControl.MessageFailures.Api -{ - using System.Collections.Generic; - using System.Threading.Tasks; - using Infrastructure.Auth; - using Infrastructure.WebApi; - using Microsoft.AspNetCore.Authorization; - using Microsoft.AspNetCore.Mvc; - using Persistence.Infrastructure; - using ServiceControl.Persistence; - - [ApiController] - [Route("api")] - public class QueueAddressController(IQueueAddressStore store) : ControllerBase - { - [Authorize(Policy = Permissions.ErrorQueuesView)] - [Route("errors/queues/addresses")] - [HttpGet] - public async Task> GetAddresses([FromQuery] PagingInfo pagingInfo) - { - var result = await store.GetAddresses(pagingInfo); - - Response.WithQueryStatsAndPagingInfo(result.QueryStats, pagingInfo); +namespace ServiceControl.MessageFailures.Api; - return result.Results; - } +using System.Collections.Generic; +using System.Threading.Tasks; +using Infrastructure.Auth; +using Infrastructure.WebApi; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Persistence.Infrastructure; +using ServiceControl.Persistence; - [Authorize(Policy = Permissions.ErrorQueuesView)] - [Route("errors/queues/addresses/search/{search}")] - [HttpGet] - public async Task>> GetAddressesBySearchTerm([FromQuery] PagingInfo pagingInfo, string search = null) - { - if (string.IsNullOrWhiteSpace(search)) - { - return BadRequest(); - } - - var result = await store.GetAddressesBySearchTerm(search, pagingInfo); +[ApiController] +[Route("api")] +public class QueueAddressController(IQueueAddressStore store) : ControllerBase +{ + [Authorize(Policy = Permissions.ErrorQueuesView)] + [Route("errors/queues/addresses")] + [HttpGet] + public async Task> GetAddresses([FromQuery] PagingInfo pagingInfo) + { + var result = await store.GetAddresses(pagingInfo); - Response.WithQueryStatsAndPagingInfo(result.QueryStats, pagingInfo); + Response.WithQueryStatsAndPagingInfo(result.QueryStats, pagingInfo); - return Ok(result.Results); - } + return result.Results; } } \ No newline at end of file