Skip to content

Commit 4e45a9f

Browse files
committed
add template_id filter
1 parent 302ebad commit 4e45a9f

3 files changed

Lines changed: 25 additions & 10 deletions

File tree

backend/modules/evaluation/application/convertor/experiment/filter.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,15 @@ func (e *ExptFilterConvertor) ConvertFilters(ctx context.Context, filters *domai
174174
}
175175
sourceIDs := parseStringList(cond.GetValue())
176176
ff.SourceID = intersectIgnoreNull(ff.SourceID, sourceIDs)
177+
case domain_expt.FieldType_ExperimentTemplateID:
178+
if len(cond.GetValue()) == 0 {
179+
continue
180+
}
181+
ids, err := parseIntList(cond.GetValue())
182+
if err != nil {
183+
return nil, err
184+
}
185+
ff.ExptTemplateIDs = intersectIgnoreNull(ff.ExptTemplateIDs, ids)
177186
default:
178187
logs.CtxWarn(ctx, "ConvertFilters with unsupport condition: %v", json.Jsonify(cond))
179188
}

backend/modules/evaluation/domain/entity/expt_result.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -337,22 +337,23 @@ type ExptListFilter struct {
337337
}
338338

339339
type ExptFilterFields struct {
340-
CreatedBy []string
341-
Status []int64
342-
EvalSetIDs []int64
343-
TargetIDs []int64
344-
EvaluatorIDs []int64
345-
TargetType []int64
346-
ExptType []int64
347-
SourceType []int64
348-
SourceID []string
340+
CreatedBy []string
341+
Status []int64
342+
EvalSetIDs []int64
343+
TargetIDs []int64
344+
EvaluatorIDs []int64
345+
TargetType []int64
346+
ExptType []int64
347+
SourceType []int64
348+
SourceID []string
349+
ExptTemplateIDs []int64
349350
}
350351

351352
func (e *ExptFilterFields) IsValid() bool {
352353
if e == nil {
353354
return true
354355
}
355-
for _, slice := range [][]int64{e.Status, e.EvalSetIDs, e.TargetIDs, e.EvaluatorIDs, e.TargetType} {
356+
for _, slice := range [][]int64{e.Status, e.EvalSetIDs, e.TargetIDs, e.EvaluatorIDs, e.TargetType, e.ExptTemplateIDs} {
356357
for _, item := range slice {
357358
if item < 0 {
358359
return false

backend/modules/evaluation/infra/repo/experiment/mysql/expt.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ func (d *exptDAOImpl) toConditions(f *entity.ExptListFilter, orders []*entity.Or
217217
return db.Where(fmt.Sprintf("%sexpt_type %s (?)", exptPrefix, scopeComparator), ffields.ExptType)
218218
})
219219
}
220+
if ffields != nil && len(ffields.ExptTemplateIDs) > 0 {
221+
conds = append(conds, func(db *gorm.DB) *gorm.DB {
222+
return db.Where(fmt.Sprintf("%sexpt_template_id %s (?)", exptPrefix, scopeComparator), ffields.ExptTemplateIDs)
223+
})
224+
}
220225
if ffields != nil && len(ffields.SourceType) > 0 {
221226
conds = append(conds, func(db *gorm.DB) *gorm.DB {
222227
return db.Where(fmt.Sprintf("%ssource_type %s (?)", exptPrefix, scopeComparator), ffields.SourceType)

0 commit comments

Comments
 (0)