Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion api/accomodation/hostel.controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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",
Expand Down
7 changes: 4 additions & 3 deletions db/gen/gate-management-for-app.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions db/queries/gate-management-for-app.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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)
),
Expand All @@ -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 (
Expand Down