feat: add book categorisation in transcripts

This commit is contained in:
Krispire Admin
2026-06-17 12:40:19 +05:30
parent a63ef672bb
commit be4b1636c0
3 changed files with 100 additions and 0 deletions
+24
View File
@@ -3,6 +3,7 @@ package handler
import (
"net/http"
"strconv"
"strings"
"github.com/go-chi/chi/v5"
"github.com/prabhupadasays/spsays-bff/internal/repository"
@@ -70,6 +71,29 @@ func (h *TranscriptionHandler) GetByType(w http.ResponseWriter, r *http.Request)
response.JSON(w, http.StatusOK, docs)
}
func (h *TranscriptionHandler) GetBooks(w http.ResponseWriter, r *http.Request) {
docs, err := h.repo.GetBooks(r.Context())
if err != nil {
response.Error(w, http.StatusInternalServerError, "failed to fetch books")
return
}
response.JSON(w, http.StatusOK, docs)
}
func (h *TranscriptionHandler) GetByBook(w http.ResponseWriter, r *http.Request) {
code := strings.ToUpper(chi.URLParam(r, "book"))
if h.repo.BookTitle(code) == "" {
response.Error(w, http.StatusNotFound, "unknown book")
return
}
docs, err := h.repo.GetByBook(r.Context(), code)
if err != nil {
response.Error(w, http.StatusInternalServerError, "failed to fetch transcriptions")
return
}
response.JSON(w, http.StatusOK, docs)
}
func (h *TranscriptionHandler) GetYears(w http.ResponseWriter, r *http.Request) {
docs, err := h.repo.GetYears(r.Context())
if err != nil {