refactor(db): GetCollectionItemsForDashboard embeds the media row; excluded filter moves into SQL; third converter dies

SELECT mi.*, ci.excluded forced every caller to filter tombstone
exclusions in Go over a 69-field row, then a 45-field hand converter
(getCollectionItemsRowToMediaItems) copied it field-by-field into
MediaItems for BuildSections. The query now filters
(ci.excluded IS NOT TRUE) itself and returns sqlc.embed(mi) — callers
consume .MediaItems directly, the Go filter loops die in both
collection-detail ladders (JSON + SSR), and the converter is deleted.

Pins, H1/H3 tests, unit suites green.
This commit is contained in:
John O'Keefe committed 2026-10-17 16:51:30 -04:00
1 parent 18727fef93
commit 77cf0b827b
7 files changed
+102 -218

No files matched your search

+3 -7
View File
@@ -293,13 +293,9 @@ func (h *CollectionHandler) GetCollection(c *echo.Context) error {
if collErr != nil {
bookList = BookCardsFromCollectionDashRows(nil, libTypes)
} else {
var validItems []database.GetCollectionItemsForDashboardRow
for _, item := range collItems {
if !item.Excluded.Valid || !item.Excluded.Bool {
validItems = append(validItems, item)
}
}
bookList = BookCardsFromCollectionDashRows(validItems, libTypes)
// The query filters excluded rows in SQL; cards build straight
// from the embedded media rows.
bookList = BookCardsFromCollectionDashRows(collItems, libTypes)
}
} else {
books, booksErr := h.GetCollectionBooksData(c, collectionID)