Skip to content

Commit f0180d6

Browse files
committed
[GEN-1863] Swaps pagination + Filtering
Add multiple filter parameters to GetPaginatedAsync method including status, provider, node/wallet IDs, user ID, manual flag, and date range. Implement corresponding UI filters in Swaps page with autocomplete components for improved data navigation and search capabilities. stack-info: PR: #483, branch: Jossec101/stack/16
1 parent 758a769 commit f0180d6

3 files changed

Lines changed: 223 additions & 62 deletions

File tree

src/Data/Repositories/Interfaces/ISwapOutRepository.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,17 @@ public interface ISwapOutRepository
2626
{
2727
Task<SwapOut?> GetById(int id);
2828
Task<List<SwapOut>> GetByIds(List<int> ids);
29-
Task<(List<SwapOut> swaps, int totalCount)> GetPaginatedAsync(int pageNumber, int pageSize);
29+
Task<(List<SwapOut> swaps, int totalCount)> GetPaginatedAsync(
30+
int pageNumber,
31+
int pageSize,
32+
SwapOutStatus? status = null,
33+
SwapProvider? provider = null,
34+
int? nodeId = null,
35+
int? walletId = null,
36+
string? userId = null,
37+
bool? isManual = null,
38+
DateTimeOffset? fromDate = null,
39+
DateTimeOffset? toDate = null);
3040
Task<List<SwapOut>> GetAllPending();
3141
Task<(bool, string?)> AddAsync(SwapOut swap);
3242
Task<(bool, string?)> AddRangeAsync(List<SwapOut> swaps);

src/Data/Repositories/SwapOutRepository.cs

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,17 @@ public async Task<List<SwapOut>> GetByIds(List<int> ids)
6060
return swaps;
6161
}
6262

63-
public async Task<(List<SwapOut> swaps, int totalCount)> GetPaginatedAsync(int pageNumber, int pageSize)
63+
public async Task<(List<SwapOut> swaps, int totalCount)> GetPaginatedAsync(
64+
int pageNumber,
65+
int pageSize,
66+
SwapOutStatus? status = null,
67+
SwapProvider? provider = null,
68+
int? nodeId = null,
69+
int? walletId = null,
70+
string? userId = null,
71+
bool? isManual = null,
72+
DateTimeOffset? fromDate = null,
73+
DateTimeOffset? toDate = null)
6474
{
6575
await using var context = await _dbContextFactory.CreateDbContextAsync();
6676

@@ -69,7 +79,33 @@ public async Task<List<SwapOut>> GetByIds(List<int> ids)
6979
.ThenInclude(w => w!.Keys)
7080
.Include(s => s.UserRequestor)
7181
.Include(s => s.Node)
72-
.OrderByDescending(s => s.CreationDatetime);
82+
.AsQueryable();
83+
84+
if (status.HasValue)
85+
query = query.Where(s => s.Status == status.Value);
86+
87+
if (provider.HasValue)
88+
query = query.Where(s => s.Provider == provider.Value);
89+
90+
if (nodeId.HasValue)
91+
query = query.Where(s => s.NodeId == nodeId.Value);
92+
93+
if (walletId.HasValue)
94+
query = query.Where(s => s.DestinationWalletId == walletId.Value);
95+
96+
if (!string.IsNullOrEmpty(userId))
97+
query = query.Where(s => s.UserRequestorId == userId);
98+
99+
if (isManual.HasValue)
100+
query = query.Where(s => s.IsManual == isManual.Value);
101+
102+
if (fromDate.HasValue)
103+
query = query.Where(s => s.CreationDatetime >= fromDate.Value);
104+
105+
if (toDate.HasValue)
106+
query = query.Where(s => s.CreationDatetime <= toDate.Value);
107+
108+
query = query.OrderByDescending(s => s.CreationDatetime);
73109

74110
var totalCount = await query.CountAsync();
75111

0 commit comments

Comments
 (0)