Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.

registry image search api added#368

Merged
nxtcoder17 merged 1 commit into
release-v1.0.7from
ref/registry-image
Sep 19, 2024
Merged

registry image search api added#368
nxtcoder17 merged 1 commit into
release-v1.0.7from
ref/registry-image

Conversation

@nxtcoder36
Copy link
Copy Markdown
Contributor

@nxtcoder36 nxtcoder36 commented Sep 17, 2024

Summary by Sourcery

Add a new search API for registry images, enabling users to perform text-based searches on image metadata. Enhance the search functionality by generating autocomplete words from metadata, and update the database indexing to support text searches.

New Features:

  • Introduce a new API endpoint for searching registry images, allowing users to query images based on metadata and other criteria.

Enhancements:

  • Add functionality to generate autocomplete words from metadata, improving search capabilities by allowing partial word matches.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Sep 17, 2024

Reviewer's Guide by Sourcery

This pull request adds a new API for searching registry images and implements the necessary backend functionality to support it. The changes include new functions for generating autocomplete words, a search function for registry images, and updates to the GraphQL schema and resolvers.

File-Level Changes

Change Details Files
Implement registry image search functionality
  • Add generatePartialWords function to create partial words for autocomplete
  • Add generateAutocompleteWords function to generate searchable metadata
  • Update CreateRegistryImage to include metadata for search
  • Implement SearchRegistryImages function with text search capability
  • Add CoreSearchRegistryImages resolver for GraphQL API
apps/console/internal/domain/registry-image.go
apps/console/internal/app/graph/schema.resolvers.go
Update database schema and indexing for text search
  • Add MetaData field to RegistryImage entity
  • Create text index on MetaData field
  • Update IndexKey struct to support text indexing
  • Modify IndexFields function to handle text indexes
apps/console/internal/entities/registry-image.go
pkg/repos/db-repo-mongo.go
pkg/repos/db-repo.go
Add GraphQL query for registry image search
  • Add Core_searchRegistryImages query to GraphQL schema
  • Update Domain interface to include SearchRegistryImages method
.tools/nvim/__http__/console/registry-image.graphql.yml
apps/console/internal/domain/api.go

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey @nxtcoder36 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider optimizing the generateAutocompleteWords function for large metadata sets. The current implementation concatenates all values, which could be inefficient for extensive metadata.
  • The SearchRegistryImages function uses a hard-coded limit of 10 results. Consider making this a parameter for more flexibility in the API.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

return partials
}

func generateAutocompleteWords(meta map[string]any) string {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Improve handling of metadata for autocomplete words generation

The current approach of concatenating all metadata values into a single string may lead to issues with spaces or special characters. Consider a more structured approach, possibly treating each key-value pair separately. Also, evaluate the performance implications for large metadata sets.

func generateAutocompleteWords(meta map[string]any) []string {
	words := make([]string, 0, len(meta))
	for key, value := range meta {
		words = append(words, fmt.Sprintf("%v:%v", key, value))
	}
	return words
}

@nxtcoder17 nxtcoder17 merged commit 2fc2179 into release-v1.0.7 Sep 19, 2024
@nxtcoder17 nxtcoder17 deleted the ref/registry-image branch September 19, 2024 11:30
abdheshnayak pushed a commit that referenced this pull request Nov 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants