refactor: dedupe anime warnings
This commit is contained in:
@@ -203,17 +203,7 @@ func (h *AnimeHandler) renderCatalogSection(c *gin.Context, section string) {
|
|||||||
userID := server.CurrentUserID(c)
|
userID := server.CurrentUserID(c)
|
||||||
data, err := h.svc.GetCatalogSection(c.Request.Context(), userID, section)
|
data, err := h.svc.GetCatalogSection(c.Request.Context(), userID, section)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
observability.Warn(
|
h.abortSectionFetch(c, "catalog_section_fetch_failed", userID, section, err)
|
||||||
"catalog_section_fetch_failed",
|
|
||||||
"anime",
|
|
||||||
"",
|
|
||||||
map[string]any{
|
|
||||||
"section": section,
|
|
||||||
"user_id": userID,
|
|
||||||
},
|
|
||||||
err,
|
|
||||||
)
|
|
||||||
c.AbortWithStatus(http.StatusInternalServerError)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,17 +265,7 @@ func (h *AnimeHandler) renderDiscoverSection(c *gin.Context, section string) {
|
|||||||
userID := server.CurrentUserID(c)
|
userID := server.CurrentUserID(c)
|
||||||
data, err := h.svc.GetDiscoverSection(c.Request.Context(), userID, section)
|
data, err := h.svc.GetDiscoverSection(c.Request.Context(), userID, section)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
observability.Warn(
|
h.abortSectionFetch(c, "discover_section_fetch_failed", userID, section, err)
|
||||||
"discover_section_fetch_failed",
|
|
||||||
"anime",
|
|
||||||
"",
|
|
||||||
map[string]any{
|
|
||||||
"section": section,
|
|
||||||
"user_id": userID,
|
|
||||||
},
|
|
||||||
err,
|
|
||||||
)
|
|
||||||
c.AbortWithStatus(http.StatusInternalServerError)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,6 +277,20 @@ func (h *AnimeHandler) renderDiscoverSection(c *gin.Context, section string) {
|
|||||||
c.HTML(http.StatusOK, "discover.gohtml", data)
|
c.HTML(http.StatusOK, "discover.gohtml", data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *AnimeHandler) abortSectionFetch(c *gin.Context, event string, userID string, section string, err error) {
|
||||||
|
observability.Warn(
|
||||||
|
event,
|
||||||
|
"anime",
|
||||||
|
"",
|
||||||
|
map[string]any{
|
||||||
|
"section": section,
|
||||||
|
"user_id": userID,
|
||||||
|
},
|
||||||
|
err,
|
||||||
|
)
|
||||||
|
c.AbortWithStatus(http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
|
||||||
func (h *AnimeHandler) HandleSchedule(c *gin.Context) {
|
func (h *AnimeHandler) HandleSchedule(c *gin.Context) {
|
||||||
user := server.CurrentUser(c)
|
user := server.CurrentUser(c)
|
||||||
year, week := parseYearWeek(c)
|
year, week := parseYearWeek(c)
|
||||||
|
|||||||
Reference in New Issue
Block a user