Skip to content

Commit

Permalink
Restrict algolia node index fields. (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
robinjhuang authored Sep 11, 2024
1 parent 452a761 commit ef094c9
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions gateways/algolia/algolia.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,25 @@ func NewFromEnvOrNoop() (AlgoliaService, error) {
// IndexNodes indexes the provided nodes in Algolia.
func (a *algolia) IndexNodes(ctx context.Context, nodes ...*ent.Node) error {
index := a.client.InitIndex("nodes_index")
objects := make([]struct {
ObjectID string `json:"objectID"`
*ent.Node
}, len(nodes))
objects := make([]map[string]interface{}, len(nodes))

for i, n := range nodes {
o := struct {
ObjectID string `json:"objectID"`
*ent.Node
}{
ObjectID: n.ID,
Node: n,
o := map[string]interface{}{
"objectID": n.ID,
"name": n.Name,
"publiser_id": n.PublisherID,
"description": n.Description,
"id": n.ID,
"create_time": n.CreateTime,
"update_time": n.UpdateTime,
"license": n.License,
"repository_url": n.RepositoryURL,
"total_install": n.TotalInstall,
"status": n.Status,
"author": n.Author,
"category": n.Category,
"total_star": n.TotalStar,
"total_review": n.TotalReview,
}
objects[i] = o
}
Expand Down

0 comments on commit ef094c9

Please sign in to comment.