Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions catalog/internal/catalog/db_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ func (d *dbCatalogImpl) GetFilterOptions(ctx context.Context) (*apimodels.Filter
Value: filter.Value,
}
}
d.applyMinMax(apiFieldFilters, options)
apiNamedQueries[queryName] = apiFieldFilters
}

Expand All @@ -266,6 +267,37 @@ func (d *dbCatalogImpl) GetFilterOptions(ctx context.Context) (*apimodels.Filter
}, nil
}

func (d *dbCatalogImpl) applyMinMax(query map[string]apimodels.FieldFilter, options map[string]apimodels.FilterOption) {
// Find queries where the value is min or max and replace it with the
// actual min or max from the filter options.
for key, filter := range query {
// Find string values that are either min or max
value, ok := filter.Value.(string)
if !ok || (value != "min" && value != "max") {
continue
}

option, ok := options[key]
if !ok || option.Range == nil {
// Skip fields without a corresponding option or options without a range.
continue
}

switch value {
case "min":
if option.Range.Min != nil {
filter.Value = *option.Range.Min
}
case "max":
if option.Range.Max != nil {
filter.Value = *option.Range.Max
}
}

query[key] = filter
}
}

func (d *dbCatalogImpl) GetPerformanceArtifacts(ctx context.Context, modelName string, sourceID string, params ListPerformanceArtifactsParams) (apimodels.CatalogArtifactList, error) {
// Get the model to validate it exists and get its ID
modelsList, err := d.catalogModelRepository.List(dbmodels.CatalogModelListOptions{
Expand Down
Loading
Loading