refactor(cards): series books JSON through the builder
GET /api/series/detail?name=… books array via BookCardsFromMediaItems. Series had the third LibraryTypeMap call INSIDE its per-item loop — ListLibraries ran once per book on the page; now once per request.
This commit is contained in:
1 parent
c07dba4eff
commit
2f9d5b8e45
1 file changed
+1
-14
@@ -3,7 +3,6 @@ package handlers
|
||||
import (
|
||||
"bookhoard/internal/database"
|
||||
"bookhoard/internal/services"
|
||||
"bookhoard/internal/utils"
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
@@ -153,19 +152,7 @@ func (h *SeriesHandler) GetSeriesBooks(c *echo.Context) error {
|
||||
return c.JSON(http.StatusInternalServerError, map[string]string{"error": "Failed to load series books"})
|
||||
}
|
||||
|
||||
bookCards := make([]BookInfo, 0, len(books))
|
||||
for _, item := range books {
|
||||
itemUUID, _ := uuid.FromBytes(item.ID.Bytes[0:16])
|
||||
libTypes := LibraryTypeMap(c.Request().Context(), h.db)
|
||||
bookCards = append(bookCards, BookInfo{
|
||||
MediaItemID: itemUUID.String(),
|
||||
Title: item.Title,
|
||||
Author: textToString(item.Author),
|
||||
CoverImagePath: utils.ResolveMediaURL(item.LibraryID, item.CoverImagePath),
|
||||
FormatGroup: item.FormatGroup,
|
||||
Badge: MediaBadgeKind(item.FormatGroup, libTypes[uuid.UUID(item.LibraryID.Bytes).String()]),
|
||||
})
|
||||
}
|
||||
bookCards := BookCardsFromMediaItems(books, LibraryTypeMap(c.Request().Context(), h.db))
|
||||
|
||||
return c.JSON(http.StatusOK, map[string]interface{}{
|
||||
"name": seriesName,
|
||||
|
||||
Reference in new issue
Block a user