From 9daf364d6115e9698192cb972e596f48fe7caa19 Mon Sep 17 00:00:00 2001 From: Evan Jarrett Date: Tue, 21 Oct 2025 22:32:16 -0500 Subject: [PATCH] make sure we return annotations on multi-arch manifests --- pkg/appview/db/queries.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pkg/appview/db/queries.go b/pkg/appview/db/queries.go index b9d12a2..196b6c7 100644 --- a/pkg/appview/db/queries.go +++ b/pkg/appview/db/queries.go @@ -310,17 +310,39 @@ func GetUserRepositories(db *sql.DB, did string) ([]Repository, error) { } // GetRepositoryMetadata retrieves metadata for a repository from its most recent manifest +// Prioritizes manifests with non-empty metadata fields func GetRepositoryMetadata(db *sql.DB, did string, repository string) (title, description, sourceURL, documentationURL, licenses, iconURL, readmeURL string, err error) { var titleNull, descriptionNull, sourceURLNull, documentationURLNull, licensesNull, iconURLNull, readmeURLNull sql.NullString + // Try to find a manifest with metadata first (prefer manifests with any non-empty annotation field) err = db.QueryRow(` SELECT title, description, source_url, documentation_url, licenses, icon_url, readme_url FROM manifests WHERE did = ? AND repository = ? + AND ( + (title IS NOT NULL AND title != '') + OR (description IS NOT NULL AND description != '') + OR (source_url IS NOT NULL AND source_url != '') + OR (documentation_url IS NOT NULL AND documentation_url != '') + OR (licenses IS NOT NULL AND licenses != '') + OR (icon_url IS NOT NULL AND icon_url != '') + OR (readme_url IS NOT NULL AND readme_url != '') + ) ORDER BY created_at DESC LIMIT 1 `, did, repository).Scan(&titleNull, &descriptionNull, &sourceURLNull, &documentationURLNull, &licensesNull, &iconURLNull, &readmeURLNull) + // If no manifest with metadata found, fall back to latest manifest (any type) + if err == sql.ErrNoRows { + err = db.QueryRow(` + SELECT title, description, source_url, documentation_url, licenses, icon_url, readme_url + FROM manifests + WHERE did = ? AND repository = ? + ORDER BY created_at DESC + LIMIT 1 + `, did, repository).Scan(&titleNull, &descriptionNull, &sourceURLNull, &documentationURLNull, &licensesNull, &iconURLNull, &readmeURLNull) + } + if err == sql.ErrNoRows { // No manifests found - return empty strings return "", "", "", "", "", "", "", nil