fix: return updated lesson from UpdateSubModuleLesson after is_active false
GetSubModuleLessonByID filters is_active=true, so refetch failed with 500 after soft-deactivating. Use RETURNING row from the update instead. Made-with: Cursor
This commit is contained in:
parent
ce1b827768
commit
24f1aca97a
|
|
@ -1956,7 +1956,7 @@ func (h *Handler) UpdateSubModuleLesson(c *fiber.Ctx) error {
|
||||||
targetIsActive = *req.IsActive
|
targetIsActive = *req.IsActive
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := h.analyticsDB.UpdateSubModuleLesson(c.Context(), dbgen.UpdateSubModuleLessonParams{
|
updatedLesson, err := h.analyticsDB.UpdateSubModuleLesson(c.Context(), dbgen.UpdateSubModuleLessonParams{
|
||||||
SubModuleID: targetSubModuleID,
|
SubModuleID: targetSubModuleID,
|
||||||
Title: targetTitle,
|
Title: targetTitle,
|
||||||
Description: targetDescription,
|
Description: targetDescription,
|
||||||
|
|
@ -1968,17 +1968,10 @@ func (h *Handler) UpdateSubModuleLesson(c *fiber.Ctx) error {
|
||||||
DisplayOrder: targetDisplayOrder,
|
DisplayOrder: targetDisplayOrder,
|
||||||
IsActive: targetIsActive,
|
IsActive: targetIsActive,
|
||||||
ID: lessonID,
|
ID: lessonID,
|
||||||
}); err != nil {
|
|
||||||
return c.Status(fiber.StatusInternalServerError).JSON(domain.ErrorResponse{
|
|
||||||
Message: "Failed to update lesson",
|
|
||||||
Error: err.Error(),
|
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|
||||||
updatedLesson, err := h.analyticsDB.GetSubModuleLessonByID(c.Context(), lessonID)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.Status(fiber.StatusInternalServerError).JSON(domain.ErrorResponse{
|
return c.Status(fiber.StatusInternalServerError).JSON(domain.ErrorResponse{
|
||||||
Message: "Lesson updated but failed to fetch latest detail",
|
Message: "Failed to update lesson",
|
||||||
Error: err.Error(),
|
Error: err.Error(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -2989,4 +2982,3 @@ func (h *Handler) DeleteModuleCapstone(c *fiber.Ctx) error {
|
||||||
}
|
}
|
||||||
return c.JSON(domain.Response{Message: "Module capstone deleted"})
|
return c.JSON(domain.Response{Message: "Module capstone deleted"})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user