make sure we return annotations on multi-arch manifests

This commit is contained in:
Evan Jarrett
2025-10-21 22:32:16 -05:00
parent c966fab53e
commit 9daf364d61
+22
View File
@@ -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