From 90baa582bed33084b99f191c510392d65f4b333b Mon Sep 17 00:00:00 2001 From: Yared Yemane Date: Mon, 20 Apr 2026 00:48:13 -0700 Subject: [PATCH] fix: load sub-module lesson by ID regardless of active flag Course-management GET/PUT used GetSubModuleLessonByID with is_active=TRUE, which returned no row for inactive lessons. Align with other ByID lookups and allow admins to view and edit inactive lessons. Made-with: Cursor --- db/query/hierarchy.sql | 3 +-- docs/docs.go | 2 +- docs/swagger.json | 2 +- docs/swagger.yaml | 2 +- gen/db/hierarchy.sql.go | 1 - internal/web_server/handlers/hierarchy_handler.go | 2 +- 6 files changed, 5 insertions(+), 7 deletions(-) diff --git a/db/query/hierarchy.sql b/db/query/hierarchy.sql index a9956c9..f988833 100644 --- a/db/query/hierarchy.sql +++ b/db/query/hierarchy.sql @@ -98,8 +98,7 @@ ORDER BY display_order ASC, id ASC; -- name: GetSubModuleLessonByID :one SELECT * FROM sub_module_lessons -WHERE id = $1 - AND is_active = TRUE; +WHERE id = $1; -- name: GetSubModulePractices :many SELECT diff --git a/docs/docs.go b/docs/docs.go index 9784f41..3b5ba54 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -2451,7 +2451,7 @@ const docTemplate = `{ }, "/api/v1/course-management/sub-module-lessons/{lessonId}": { "get": { - "description": "Returns one active lesson detail by lesson ID", + "description": "Returns one lesson detail by lesson ID (active or inactive)", "consumes": [ "application/json" ], diff --git a/docs/swagger.json b/docs/swagger.json index 0450e43..d65ae15 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -2443,7 +2443,7 @@ }, "/api/v1/course-management/sub-module-lessons/{lessonId}": { "get": { - "description": "Returns one active lesson detail by lesson ID", + "description": "Returns one lesson detail by lesson ID (active or inactive)", "consumes": [ "application/json" ], diff --git a/docs/swagger.yaml b/docs/swagger.yaml index b052347..7778169 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -3725,7 +3725,7 @@ paths: get: consumes: - application/json - description: Returns one active lesson detail by lesson ID + description: Returns one lesson detail by lesson ID (active or inactive) parameters: - description: Lesson ID in: path diff --git a/gen/db/hierarchy.sql.go b/gen/db/hierarchy.sql.go index a48d1ac..54212ac 100644 --- a/gen/db/hierarchy.sql.go +++ b/gen/db/hierarchy.sql.go @@ -1405,7 +1405,6 @@ const GetSubModuleLessonByID = `-- name: GetSubModuleLessonByID :one SELECT id, sub_module_id, display_order, is_active, created_at, title, description, thumbnail, teaching_text, teaching_image_url, teaching_audio_url, teaching_video_url FROM sub_module_lessons WHERE id = $1 - AND is_active = TRUE ` func (q *Queries) GetSubModuleLessonByID(ctx context.Context, id int64) (SubModuleLesson, error) { diff --git a/internal/web_server/handlers/hierarchy_handler.go b/internal/web_server/handlers/hierarchy_handler.go index 0aa925d..8e249b0 100644 --- a/internal/web_server/handlers/hierarchy_handler.go +++ b/internal/web_server/handlers/hierarchy_handler.go @@ -1857,7 +1857,7 @@ func (h *Handler) GetSubModuleLessons(c *fiber.Ctx) error { // GetSubModuleLessonByID godoc // @Summary Get lesson detail -// @Description Returns one active lesson detail by lesson ID +// @Description Returns one lesson detail by lesson ID (active or inactive) // @Tags course-management // @Accept json // @Produce json