Skip to content

Commit

Permalink
fix: find ids funcs should return the uuids
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe authored and moshloop committed Feb 1, 2024
1 parent 22eb032 commit 8366a08
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions getters.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,12 @@ func apply(db *gorm.DB, opts ...FindOption) *gorm.DB {
return db
}

func FindCheckIDs(ctx context.Context, resourceSelector types.ResourceSelector) ([]models.Check, error) {
return FindChecks(ctx, []types.ResourceSelector{resourceSelector}, PickColumns("id"))
func FindCheckIDs(ctx context.Context, resourceSelector types.ResourceSelector) ([]uuid.UUID, error) {
items, err := FindChecks(ctx, []types.ResourceSelector{resourceSelector}, PickColumns("id"))
if err != nil {
return nil, err
}
return lo.Map(items, func(c models.Check, _ int) uuid.UUID { return c.ID }), nil
}

func FindChecks(ctx context.Context, resourceSelectors types.ResourceSelectors, opts ...FindOption) ([]models.Check, error) {
Expand Down Expand Up @@ -214,8 +218,12 @@ func FindChecks(ctx context.Context, resourceSelectors types.ResourceSelectors,
return lo.UniqBy(allChecks, models.CheckID), nil
}

func FindComponentIDs(ctx context.Context, resourceSelector types.ResourceSelector) ([]models.Component, error) {
return FindComponents(ctx, []types.ResourceSelector{resourceSelector}, PickColumns("id"))
func FindComponentIDs(ctx context.Context, resourceSelector types.ResourceSelector) ([]uuid.UUID, error) {
items, err := FindComponents(ctx, []types.ResourceSelector{resourceSelector}, PickColumns("id"))
if err != nil {
return nil, err
}
return lo.Map(items, func(c models.Component, _ int) uuid.UUID { return c.ID }), nil
}

func FindComponents(ctx context.Context, resourceSelectors types.ResourceSelectors, opts ...FindOption) ([]models.Component, error) {
Expand Down Expand Up @@ -286,8 +294,12 @@ func FindComponents(ctx context.Context, resourceSelectors types.ResourceSelecto
return lo.UniqBy(allComponents, models.ComponentID), nil
}

func FindConfigIDs(ctx context.Context, resourceSelector types.ResourceSelector) ([]models.ConfigItem, error) {
return FindConfigs(ctx, []types.ResourceSelector{resourceSelector}, PickColumns("id"))
func FindConfigIDs(ctx context.Context, resourceSelector types.ResourceSelector) ([]uuid.UUID, error) {
items, err := FindConfigs(ctx, []types.ResourceSelector{resourceSelector}, PickColumns("id"))
if err != nil {
return nil, err
}
return lo.Map(items, func(c models.ConfigItem, _ int) uuid.UUID { return c.ID }), nil
}

func FindConfigs(ctx context.Context, resourceSelectors types.ResourceSelectors, opts ...FindOption) ([]models.ConfigItem, error) {
Expand Down

0 comments on commit 8366a08

Please sign in to comment.