func EquipmentSearch(ctx context.Context, client *ent.Client, filters []*models.EquipmentFilterInput, limit *int) (*models.EquipmentSearchResult, error) {
	var (
		res []*ent.Equipment
		c   int
		err error
	)
	// TODO T46957221 support query Clone
	for i := 0; i < 2; i++ {
		query := client.Equipment.Query()
		for _, f := range filters {
			switch {
			case strings.HasPrefix(f.FilterType.String(), "EQUIPMENT_TYPE"):
				if query, err = handleEquipmentTypeFilter(query, f); err != nil {
					return nil, err
				}
			case strings.HasPrefix(f.FilterType.String(), "EQUIP_INST"), strings.HasPrefix(f.FilterType.String(), "PROPERTY"):
				if query, err = handleEquipmentFilter(query, f); err != nil {
					return nil, err
				}
			case strings.HasPrefix(f.FilterType.String(), "LOCATION_INST"):
				if query, err = handleEquipmentLocationFilter(query, f); err != nil {
					return nil, err
				}
			}
		}
		if i == 0 {
			c, err = query.Count(ctx)
			if err != nil {
				return nil, err
			}
			continue
		}
		if limit != nil {
			query.Limit(*limit)
		}
		res, err = query.Order(ent.Asc(equipment.FieldName)).All(ctx)
		if err != nil {
			return nil, err
		}
	}

	return &models.EquipmentSearchResult{
		Equipment: res,
		Count:     c,
	}, err
}
// EquipmentTypes is a helper to bring equipment types
EquipmentTypes is a helper to bring equipment types
// EquipmentTypes is a helper to bring equipment types
func EquipmentSearch(ctx context.Context, client *ent.Client, filters []*models.EquipmentFilterInput, limit *int) (*models.EquipmentSearchResult, error) {
	var (
		res []*ent.Equipment
		c   int
		err error
	)
	for i := 0; i < 2; i++ {
		query := client.Equipment.Query()
		for _, f := range filters {
			switch {
			case strings.HasPrefix(f.FilterType.String(), "EQUIPMENT_TYPE"):
				if query, err = handleEquipmentTypeFilter(query, f); err != nil {
					return nil, err
				}
			case strings.HasPrefix(f.FilterType.String(), "EQUIP_INST"), strings.HasPrefix(f.FilterType.String(), "PROPERTY"):
				if query, err = handleEquipmentFilter(query, f); err != nil {
					return nil, err
				}
			case strings.HasPrefix(f.FilterType.String(), "LOCATION_INST"):
				if query, err = handleEquipmentLocationFilter(query, f); err != nil {
					return nil, err
				}
			}
		}
		if i == 0 {
			c, err = query.Count(ctx)
			if err != nil {
				return nil, err
			}
			continue
		}
		if limit != nil {
			query.Limit(*limit)
		}
		res, err = query.Order(ent.Asc(equipment.FieldName)).All(ctx)
		if err != nil {
			return nil, err
		}
	}
	return &models.EquipmentSearchResult{
		Equipment: res,
		Count:     c,
	}, err
}
func EquipmentSearch ( ctx context . Context , client * ent . Client , filters [ ] * models . EquipmentFilterInput , limit * int ) ( * models . EquipmentSearchResult , error ) { var ( res [ ] * ent . Equipment c int err error ) for i := 0 ; i < 2 ; i ++ { query := client . Equipment . Query ( ) for _ , f := range filters { switch { case strings . HasPrefix ( f . FilterType . String ( ) , " " ) : if query , err = handleEquipmentTypeFilter ( query , f ) ; err != nil { return nil , err } case strings . HasPrefix ( f . FilterType . String ( ) , " " ) , strings . HasPrefix ( f . FilterType . String ( ) , " " ) : if query , err = handleEquipmentFilter ( query , f ) ; err != nil { return nil , err } case strings . HasPrefix ( f . FilterType . String ( ) , " " ) : if query , err = handleEquipmentLocationFilter ( query , f ) ; err != nil { return nil , err } } } if i == 0 { c , err = query . Count ( ctx ) if err != nil { return nil , err } continue } if limit != nil { query . Limit ( * limit ) } res , err = query . Order ( ent . Asc ( equipment . FieldName ) ) . All ( ctx ) if err != nil { return nil , err } } return & models . EquipmentSearchResult { Equipment : res , Count : c , } , err }
EquipmentTypes is a helper to bring equipment types
EquipmentTypes is a helper to bring equipment types
// TODO T46957221 support query Clone