Skip to content

Commit

Permalink
reverse flash
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikus1993 committed Feb 11, 2024
1 parent 8997035 commit eb37a92
Showing 1 changed file with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ public async Task<PagedResult<Product>> FilterProducts(Filter filter, Cancellati

private static QueryResultMetadata GetQueryResultMetadata(ISearchResponse<OpenSearchProduct> result)
{
if (result.Aggregations is {Count: 0})
{
return QueryResultMetadata.Empty;
}

var tags = result.Aggregations.Terms("tags").Buckets.Select(x => x.DocCount.HasValue ? new TagFilterMetaData(x.Key, x.DocCount.Value) : new TagFilterMetaData(x.Key, 0));

var prices = PricesMetaData.Empty;
Expand All @@ -113,23 +118,17 @@ private static ISort[] GetSortOrder(SortOrder sortOrder)
{
return sortOrder switch
{
SortOrder.Default => Array.Empty<ISort>(),
SortOrder.PriceAsc => new ISort[]
{
new FieldSort()
SortOrder.Default => [],
SortOrder.PriceAsc => [new FieldSort()
{
Field = Field<OpenSearchProduct>(static p => p.SalePrice),
Order = OpenSearch.Client.SortOrder.Ascending
}
},
SortOrder.PriceDesc => new ISort[]
{
new FieldSort()
}],
SortOrder.PriceDesc => [new FieldSort()
{
Field = Field<OpenSearchProduct>(static p => p.SalePrice),
Order = OpenSearch.Client.SortOrder.Descending
}
},
}],
_ => throw new ArgumentOutOfRangeException(nameof(sortOrder), sortOrder, null)
};
}
Expand Down

0 comments on commit eb37a92

Please sign in to comment.