diff --git a/db/query/hierarchy.sql b/db/query/hierarchy.sql index e1204b3..13ec333 100644 --- a/db/query/hierarchy.sql +++ b/db/query/hierarchy.sql @@ -119,7 +119,6 @@ FROM sub_module_practices smp JOIN question_sets qs ON qs.id = smp.question_set_id WHERE smp.sub_module_id = $1 AND smp.is_active = TRUE - AND qs.set_type = 'PRACTICE' ORDER BY smp.display_order ASC, smp.id ASC; -- name: GetSubModulePracticeByID :one @@ -140,8 +139,7 @@ SELECT FROM sub_module_practices smp JOIN question_sets qs ON qs.id = smp.question_set_id WHERE smp.id = $1 - AND smp.is_active = TRUE - AND qs.set_type = 'PRACTICE'; + AND smp.is_active = TRUE; -- name: GetSubModuleCapstones :many SELECT diff --git a/gen/db/hierarchy.sql.go b/gen/db/hierarchy.sql.go index 19d565f..a25df45 100644 --- a/gen/db/hierarchy.sql.go +++ b/gen/db/hierarchy.sql.go @@ -1611,7 +1611,6 @@ FROM sub_module_practices smp JOIN question_sets qs ON qs.id = smp.question_set_id WHERE smp.id = $1 AND smp.is_active = TRUE - AND qs.set_type = 'PRACTICE' ` type GetSubModulePracticeByIDRow struct { @@ -1670,7 +1669,6 @@ FROM sub_module_practices smp JOIN question_sets qs ON qs.id = smp.question_set_id WHERE smp.sub_module_id = $1 AND smp.is_active = TRUE - AND qs.set_type = 'PRACTICE' ORDER BY smp.display_order ASC, smp.id ASC ` diff --git a/internal/web_server/handlers/hierarchy_handler.go b/internal/web_server/handlers/hierarchy_handler.go index ad5816d..fbb66f8 100644 --- a/internal/web_server/handlers/hierarchy_handler.go +++ b/internal/web_server/handlers/hierarchy_handler.go @@ -2229,9 +2229,14 @@ func (h *Handler) GetSubModulePractices(c *fiber.Ctx) error { Error: err.Error(), }) } + if practices == nil { + practices = []dbgen.GetSubModulePracticesRow{} + } return c.JSON(domain.Response{ - Message: "Sub-module practices retrieved successfully", + Message: "Sub-module practices retrieved successfully", + Success: true, + StatusCode: fiber.StatusOK, Data: map[string]interface{}{ "practices": practices, "total_count": len(practices),