11namespace ServiceControl . Persistence . EFCore . Implementation ;
22
3+ using Microsoft . EntityFrameworkCore ;
4+ using Microsoft . Extensions . DependencyInjection ;
35using ServiceControl . MessageFailures ;
46using ServiceControl . Persistence . Infrastructure ;
57
6- public class QueueAddressStore : IQueueAddressStore
8+ public class QueueAddressStore ( IServiceScopeFactory scopeFactory ) : DataStoreBase ( scopeFactory ) , IQueueAddressStore
79{
8- public Task < QueryResult < IList < QueueAddress > > > GetAddresses ( PagingInfo pagingInfo )
9- {
10- await exe
11- var queryable
12- }
10+ public Task < QueryResult < IList < QueueAddress > > > GetAddresses ( PagingInfo pagingInfo ) =>
11+ GetAddressesBySearchTerm ( string . Empty , pagingInfo ) ;
1312
1413 public Task < QueryResult < IList < QueueAddress > > > GetAddressesBySearchTerm ( string search , PagingInfo pagingInfo ) =>
15- throw new NotImplementedException ( ) ;
14+ ExecuteWithDbContext ( async context =>
15+ {
16+ var query = context . FailedMessages
17+ . Where ( fm => string . IsNullOrWhiteSpace ( search ) || fm . EndpointAddress . StartsWith ( search ) )
18+ . Select ( fm => new { fm . OriginalMessageIdentifier , fm . EndpointAddress } )
19+ . Distinct ( )
20+ . GroupBy ( failure => failure . EndpointAddress )
21+ . OrderBy ( failuresByEndpoint => failuresByEndpoint . Key )
22+ . Select ( failuresByEndpoint => new QueueAddress
23+ {
24+ PhysicalAddress = failuresByEndpoint . Key ,
25+ FailedMessageCount = failuresByEndpoint . Count ( )
26+ } ) ;
27+
28+ var items = await query . Skip ( pagingInfo . Offset ) . Take ( pagingInfo . PageSize ) . ToListAsync ( ) ;
29+
30+ return new QueryResult < IList < QueueAddress > > ( items , new QueryStatsInfo ( "" , query . Count ( ) , false ) ) ;
31+ } ) ;
1632}
0 commit comments