diff --git a/sort/custom_field_sort.go b/sort/custom_field_sort.go index 6f94091..61e6ea0 100644 --- a/sort/custom_field_sort.go +++ b/sort/custom_field_sort.go @@ -5,6 +5,7 @@ import ( "fmt" "sort" "strings" + "time" "github.com/alibaba/pairec/v2/log" "github.com/alibaba/pairec/v2/module" @@ -14,6 +15,7 @@ import ( type CustomFieldSort struct { sortByField string sortOrder string // "asc" 表示升序,"desc" 表示降序 + name string } func NewCustomFieldSort(config recconf.SortConfig) *CustomFieldSort { @@ -31,10 +33,12 @@ func NewCustomFieldSort(config recconf.SortConfig) *CustomFieldSort { return &CustomFieldSort{ sortByField: config.SortByField, sortOrder: sortOrder, + name: config.Name, } } func (s *CustomFieldSort) Sort(sortData *SortData) error { + start := time.Now() items, ok := sortData.Data.([]*module.Item) if !ok { return errors.New("sort data type error") @@ -61,5 +65,6 @@ func (s *CustomFieldSort) Sort(sortData *SortData) error { return iScore > jScore }) sortData.Data = items + sortInfoLogWithName(sortData, "CustomFieldSort", s.name, len(items), start) return nil }