Skip to content

Commit

Permalink
Fix broker queue filters
Browse files Browse the repository at this point in the history
  • Loading branch information
filipbekic01 committed Sep 23, 2024
1 parent 299574a commit 4c4c928
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions backend/ResQueue/ResQueue/Endpoints/QueueEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static void MapQueueEndpoints(this IEndpointRouteBuilder routes)
search = search.Trim();
sortField = new[]
{
"name", "synced", "messages"
"inbox", "name", "messages"
}.Contains(sortField)
? sortField
: null;
Expand Down Expand Up @@ -113,8 +113,15 @@ public static void MapQueueEndpoints(this IEndpointRouteBuilder routes)
if (sortField is not null && sortOrder is not null)
{
var secondarySort = sortOrder == 1
? Builders<Queue>.Sort.Ascending($"RawData.{sortField}")
: Builders<Queue>.Sort.Descending($"RawData.{sortField}");
? Builders<Queue>.Sort.Ascending(x => x.RawData[sortField])
: Builders<Queue>.Sort.Descending(x => x.RawData[sortField]);

if (sortField.Equals("inbox", StringComparison.CurrentCultureIgnoreCase))
{
secondarySort = sortOrder == 1
? Builders<Queue>.Sort.Ascending(x => x.TotalMessages)
: Builders<Queue>.Sort.Descending(x => x.TotalMessages);
}

sort = Builders<Queue>.Sort.Combine(sort, secondarySort);
}
Expand Down

0 comments on commit 4c4c928

Please sign in to comment.