From d2d92efd1015a0fbbe49fc6d251d2e24855caa8e Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Sat, 17 Oct 2026 17:31:23 -0400 Subject: [PATCH] =?UTF-8?q?refactor(vis):=20H4.5=20step=202=20=E2=80=94=20?= =?UTF-8?q?series=20endpoints=20on=20the=20canonical=20resolver?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Series' visibleLibrarySet was the third hand-rolled set builder (with its own FromBytes-error idiom, the fourth idiom in four copies). SeriesService.VisibleLibraries — a pure pass-through to GetUserVisibleLibraries — now has zero callers and dies with the migration. --- internal/handlers/series.go | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/internal/handlers/series.go b/internal/handlers/series.go index 51312991..c0ed1ecb 100644 --- a/internal/handlers/series.go +++ b/internal/handlers/series.go @@ -13,14 +13,16 @@ import ( ) type SeriesHandler struct { - seriesService *services.SeriesService - db *database.Queries + seriesService *services.SeriesService + libraryService *services.LibraryService + db *database.Queries } func NewSeriesHandler(db *database.Queries) *SeriesHandler { return &SeriesHandler{ - seriesService: services.NewSeriesService(db), - db: db, + seriesService: services.NewSeriesService(db), + libraryService: services.NewLibraryService(db), + db: db, } } @@ -104,24 +106,7 @@ func (h *SeriesHandler) visibleLibrarySet(c *echo.Context) (map[string]bool, []p if !ok { return nil, nil, echo.NewHTTPError(http.StatusUnauthorized, "invalid user") } - libraries, err := h.seriesService.VisibleLibraries(c.Request().Context(), user.ID) - if err != nil { - return nil, nil, echo.NewHTTPError(http.StatusInternalServerError, "failed to check library access") - } - set := make(map[string]bool, len(libraries)) - ids := make([]pgtype.UUID, 0, len(libraries)) - for _, lib := range libraries { - if !lib.ID.Valid { - continue - } - libUUID, err := uuid.FromBytes(lib.ID.Bytes[0:16]) - if err != nil { - continue - } - set[libUUID.String()] = true - ids = append(ids, lib.ID) - } - return set, ids, nil + return h.libraryService.VisibleLibrarySet(c.Request().Context(), user.ID) } func (h *SeriesHandler) GetSeriesBooks(c *echo.Context) error {