func()

in domain/sequence_feature_view.go [236:274]


func (f *SequenceFeatureView) GetBehaviorFeatures(userIds []interface{}, events []interface{}, features []string) ([]map[string]interface{}, error) {
	var selectFields []string
	seenFields := make(map[string]bool)

	for _, feature := range features {
		if feature == "*" {
			selectFields = append(selectFields, f.behaviorFields...)
			break
		} else {
			if seenFields[feature] {
				continue
			}
			found := false
			for _, field := range f.behaviorFields {
				if field == feature {
					found = true
					break
				}
			}
			if !found {
				return nil, fmt.Errorf("behavior feature name :%s not found in feature view config", feature)
			}

			selectFields = append(selectFields, feature)
			seenFields[feature] = true
		}
	}

	behaviorFeatureResult, err := f.featureViewDao.GetUserBehaviorFeature(userIds, events, selectFields, f.sequenceConfig)

	if f.userIdField != f.FeatureEntity.FeatureEntityJoinid {
		for _, behaviorFeatureMap := range behaviorFeatureResult {
			behaviorFeatureMap[f.FeatureEntity.FeatureEntityJoinid] = behaviorFeatureMap[f.userIdField]
			delete(behaviorFeatureMap, f.userIdField)
		}
	}

	return behaviorFeatureResult, err
}