Skip to content

Commit

Permalink
chore: clean marketplace service
Browse files Browse the repository at this point in the history
Signed-off-by: Norman Meier <[email protected]>
  • Loading branch information
n0izn0iz committed Aug 2, 2023
1 parent 29a6f02 commit a0738b2
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions go/pkg/marketplace/marketplace_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -990,15 +990,13 @@ func (s *MarkteplaceService) SearchNames(ctx context.Context, req *marketplacepb
}
}

var dbNames []indexerdb.Name
if err := s.conf.IndexerDB.Limit(int(limit)).Where("names.value ~* ?", req.Input).Find(&dbNames).Error; err != nil {
return nil, errors.Wrap(err, "failed to read names db")
}

s.conf.Logger.Info("search names", zap.Int("db", len(dbNames)))

missing := int(limit) - len(names)
if missing > 0 {
var dbNames []indexerdb.Name
if err := s.conf.IndexerDB.Limit(missing).Where("names.value ~* ?", req.Input).Find(&dbNames).Error; err != nil {
return nil, errors.Wrap(err, "failed to read names db")
}
s.conf.Logger.Info("search names", zap.Int("db", len(dbNames)))
for _, n := range dbNames[:min(missing, len(dbNames))] {
names = append(names, n.Value)
}
Expand Down

0 comments on commit a0738b2

Please sign in to comment.