Skip to content

Commit

Permalink
index node versions
Browse files Browse the repository at this point in the history
  • Loading branch information
james03160927 committed Sep 9, 2024
1 parent 4f92246 commit d453cff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions gateways/algolia/algolia.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,14 @@ func (a *algolia) IndexNodes(ctx context.Context, nodes ...*ent.Node) error {
}, len(nodes))

for i, n := range nodes {
objects[i] = struct {
o := struct {
ObjectID string `json:"objectID"`
*ent.Node
}{
ObjectID: n.ID,
Node: n,
}
objects[i] = o
}

res, err := index.SaveObjects(objects)
Expand Down Expand Up @@ -118,13 +119,15 @@ func (a *algolia) IndexNodeVersions(ctx context.Context, nodes ...*ent.NodeVersi
}, len(nodes))

for i, n := range nodes {
objects[i] = struct {
o := struct {
ObjectID string `json:"objectID"`
*ent.NodeVersion
}{
ObjectID: n.ID.String(),
NodeVersion: n,
}
o.StatusReason = ""
objects[i] = o
}

res, err := index.SaveObjects(objects)
Expand Down
4 changes: 2 additions & 2 deletions services/registry/registry_svc.go
Original file line number Diff line number Diff line change
Expand Up @@ -876,10 +876,10 @@ func (s *RegistryService) ReindexAllNodes(ctx context.Context, client *ent.Clien
return fmt.Errorf("failed to reindex all nodes: %w", err)
}

log.Ctx(ctx).Info().Msgf("reindexing %d number of nodes version", len(nvs))
log.Ctx(ctx).Info().Msgf("reindexing %d number of node versions", len(nvs))
err = s.algolia.IndexNodeVersions(ctx, nvs...)
if err != nil {
return fmt.Errorf("failed to reindex all nodes: %w", err)
return fmt.Errorf("failed to reindex all node versions: %w", err)
}
return nil
}
Expand Down

0 comments on commit d453cff

Please sign in to comment.