From 43e202dadde8b899997064b18482b19c51380c8b Mon Sep 17 00:00:00 2001 From: Ritesh Koushik Date: Tue, 6 Jan 2026 06:50:23 +0530 Subject: [PATCH 1/3] fix: Missing typo --- api/accomodation/hostel.controllers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/accomodation/hostel.controllers.go b/api/accomodation/hostel.controllers.go index 9db33b14..3e2e562d 100644 --- a/api/accomodation/hostel.controllers.go +++ b/api/accomodation/hostel.controllers.go @@ -28,7 +28,7 @@ func HostelCheckIn(c *gin.Context) { defer cancel() conn, err := cmd.DBPool.Acquire(ctx) - if pkg.HandleDbAcquireErr(c, err, "") { + if pkg.HandleDbAcquireErr(c, err, "HOSTEL") { return } defer conn.Release() From eea758eb91a2cd8b3a2d3369a994f615a8bc18cb Mon Sep 17 00:00:00 2001 From: Ritesh Koushik Date: Tue, 6 Jan 2026 06:52:22 +0530 Subject: [PATCH 2/3] fix: Missing error handling for DB --- api/accomodation/hostel.controllers.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/api/accomodation/hostel.controllers.go b/api/accomodation/hostel.controllers.go index 3e2e562d..9251d257 100644 --- a/api/accomodation/hostel.controllers.go +++ b/api/accomodation/hostel.controllers.go @@ -38,6 +38,13 @@ func HostelCheckIn(c *gin.Context) { HospitalityID: pgtype.Text{String: hospId, Valid: true}, CheckedInBy: personellId, }) + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{ + "message": "Oops! Something happened. Please try again later", + }) + pkg.Log.ErrorCtx(c, "[HOSTEL-ERROR]: Failed to hostel check-in", err) + return + } c.JSON(http.StatusOK, gin.H{ "message": "Hostel check-in successful", From 42fe2bbf0479488544cc72395fe7e3228ec6d7ab Mon Sep 17 00:00:00 2001 From: Ritesh Koushik Date: Tue, 6 Jan 2026 06:57:35 +0530 Subject: [PATCH 3/3] fix: HostelCheckIn query fixed --- db/gen/gate-management-for-app.sql.go | 7 ++++--- db/queries/gate-management-for-app.sql | 9 +++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/db/gen/gate-management-for-app.sql.go b/db/gen/gate-management-for-app.sql.go index 5e2faaad..8a2cc558 100644 --- a/db/gen/gate-management-for-app.sql.go +++ b/db/gen/gate-management-for-app.sql.go @@ -85,10 +85,10 @@ const hostelCheckInQuery = `-- name: HostelCheckInQuery :one WITH student_lookup AS ( SELECT id FROM student - WHERE hospitality_id = $1 + WHERE student.hospitality_id = $1 ), accommodation_lookup AS ( - SELECT id, name, hostel_id + SELECT id, hostel_id, student_id FROM accomodation_details WHERE student_id = (SELECT id FROM student_lookup) ), @@ -99,11 +99,12 @@ new_check_in AS ( RETURNING accomodation_id ) SELECT - ad.name, + s.name, hm.hostel_name FROM new_check_in JOIN accomodation_details ad ON ad.id = new_check_in.accomodation_id JOIN hostel_metadata hm ON hm.id = ad.hostel_id +JOIN student s ON s.id = ad.student_id ` type HostelCheckInQueryParams struct { diff --git a/db/queries/gate-management-for-app.sql b/db/queries/gate-management-for-app.sql index 4a24b387..631d20e4 100644 --- a/db/queries/gate-management-for-app.sql +++ b/db/queries/gate-management-for-app.sql @@ -31,10 +31,10 @@ WHERE WITH student_lookup AS ( SELECT id FROM student - WHERE hospitality_id = $1 + WHERE student.hospitality_id = $1 ), accommodation_lookup AS ( - SELECT id, name, hostel_id + SELECT id, hostel_id, student_id FROM accomodation_details WHERE student_id = (SELECT id FROM student_lookup) ), @@ -45,11 +45,12 @@ new_check_in AS ( RETURNING accomodation_id ) SELECT - ad.name, + s.name, hm.hostel_name FROM new_check_in JOIN accomodation_details ad ON ad.id = new_check_in.accomodation_id -JOIN hostel_metadata hm ON hm.id = ad.hostel_id; +JOIN hostel_metadata hm ON hm.id = ad.hostel_id +JOIN student s ON s.id = ad.student_id; -- name: HostelGateStatusQuery :one WITH student_info AS (