refactor(cards): smart-collection preview through the builder

POST preview-feed had the ladder's 14th hand-rolled literal. Now
BookCardsFromMediaItems + one LibraryTypeMap per request; the response
carries format_group/badge values for the first time (all seven keys
were already emitted as zero-value JSON, so this is a value change on
a pin-frozen shape, not a key change).
This commit is contained in:
John O'Keefe committed 2026-10-17 14:02:43 -04:00
1 parent 23765934ef
commit c07dba4eff
1 file changed
+1 -10
+1 -10
View File
@@ -1251,16 +1251,7 @@ func (h *CollectionHandler) PreviewCollection(c *echo.Context) error {
matchedItems = matchedItems[:req.Limit]
}
bookCards := make([]BookInfo, len(matchedItems))
for i, item := range matchedItems {
itemUUID, _ := uuid.FromBytes(item.ID.Bytes[0:16])
bookCards[i] = BookInfo{
MediaItemID: itemUUID.String(),
Title: item.Title,
Author: textToString(item.Author),
CoverImagePath: utils.ResolveMediaURL(item.LibraryID, item.CoverImagePath),
}
}
bookCards := BookCardsFromMediaItems(matchedItems, LibraryTypeMap(c.Request().Context(), h.db))
return c.JSON(http.StatusOK, map[string]interface{}{"items": bookCards})
}