Skip to content

Commit

Permalink
VCST-541: Product StartDate and endDate for product does not work in …
Browse files Browse the repository at this point in the history
…xapi (#538)

fix: Adds CertainDate Filter to for product search in xapi if First listed and Listing expires are configured for product.
  • Loading branch information
OlegoO committed Mar 18, 2024
1 parent 510e99a commit eab0c39
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,37 @@ public IndexSearchRequestBuilder WithIncludeFields(params string[] includeFields
return this;
}

public IndexSearchRequestBuilder AddCertainDateFilter(DateTime certainDate)
{
var startDateFilter = new RangeFilter
{
FieldName = "startdate",
Values = [new RangeFilterValue
{
Lower = null,
Upper = certainDate.ToString("O"),
IncludeLower = false,
IncludeUpper = true,
}]
};

var endDateFilter = new RangeFilter
{
FieldName = "enddate",
Values = [new RangeFilterValue
{
Lower = certainDate.ToString("O"),
Upper = null,
IncludeLower = false,
IncludeUpper = true,
}]
};

AddFiltersToSearchRequest([startDateFilter, endDateFilter]);

return this;
}

public IndexSearchRequestBuilder AddObjectIds(IEnumerable<string> ids)
{
if (!ids.IsNullOrEmpty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ protected virtual IndexSearchRequestBuilder GetIndexedSearchRequestBuilder(Searc
.WithUserId(request.UserId)
.WithCurrency(currency.Code)
.WithFuzzy(request.Fuzzy, request.FuzzyLevel)
.AddCertainDateFilter(DateTime.UtcNow)
.ParseFilters(_phraseParser, request.Filter)
.WithSearchPhrase(request.Query)
.WithPaging(request.Skip, request.Take)
Expand Down

0 comments on commit eab0c39

Please sign in to comment.