From f35defd139d91e6084eefa0f58d1333609e2a08c Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Mon, 26 Jan 2026 11:49:44 -0500 Subject: [PATCH] Update GetEbookRating API to return rating 0 when no rating exists --- internal/handlers/ebook.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/handlers/ebook.go b/internal/handlers/ebook.go index 07044a4..9877575 100644 --- a/internal/handlers/ebook.go +++ b/internal/handlers/ebook.go @@ -346,8 +346,12 @@ func (h *Handler) GetEbookRating(c echo.Context) error { }) if err != nil { if err == pgx.ErrNoRows { - // If no rating found, return 404 - return c.JSON(http.StatusNotFound, map[string]string{"error": "rating not found"}) + // If no rating found, return rating 0 + return c.JSON(http.StatusOK, map[string]interface{}{ + "ebook_id": ebookIdStr, + "user_id": userID, + "rating": 0, + }) } return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()}) }