Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: basic implementation for search for auto-completion api #112

Merged
merged 2 commits into from
Mar 5, 2022

Conversation

guacamole
Copy link
Member

  • This is the most basic implementation for auto-complete api
  • We are using index with text_pattern_ops
  • Optimisations to come as we test and integrate it with frontend

@guacamole guacamole requested a review from jay-dee7 March 5, 2022 05:05
@guacamole guacamole self-assigned this Mar 5, 2022
@jay-dee7 jay-dee7 added enhancement New feature or request P1 P1 label is used for this that we see of highest priority. Critical bugs, security issues, etc labels Mar 5, 2022
@@ -829,3 +829,15 @@ func (r *registry) ApiVersion(ctx echo.Context) error {

return ctx.String(http.StatusOK, "OK\n")
}

func (r *registry) GetImageNamespace(ctx echo.Context) error {
searchQuery := ctx.QueryParam("search_query")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guacamole can we check for emptiness here?

router/router.go Outdated
@@ -114,4 +114,6 @@ func Docker(group *echo.Group, reg registry.Registry) {

// GET /v2/_catalog
group.Add(http.MethodGet, Catalog, reg.Catalog)
group.Add(http.MethodGet, "/search", reg.GetImageNamespace)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets put this in a const like we did with Catalog and the path can be /v2/catalog/search

@@ -114,4 +114,6 @@ func Docker(group *echo.Group, reg registry.Registry) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also worth noting that the Function here called Docker can totally be called Extensions

defer cancel()
rows, err := p.conn.Query(childCtx, queries.GetImageNamespace, "%"+search+"%")
if err != nil {
return nil, err
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrap this error with a little description

for rows.Next() {
var ns string
if err := rows.Scan(&ns); err != nil {
return nil, err
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also this one

@jay-dee7 jay-dee7 removed the request for review from Sanyambansal76 March 5, 2022 06:03
Copy link
Member

@jay-dee7 jay-dee7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🥇 🥇 🥇

@guacamole guacamole merged commit 12f3ba4 into master Mar 5, 2022
@jay-dee7 jay-dee7 deleted the search-with-autocomplete branch March 30, 2022 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P1 P1 label is used for this that we see of highest priority. Critical bugs, security issues, etc
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants