added support for room_types (#183)

* added support for room_types

* backwards compability
This commit is contained in:
Arwid Thornström
2025-12-16 10:44:24 +01:00
committed by GitHub
parent c3f160b8ea
commit a298b3474e
2 changed files with 14 additions and 2 deletions
+13 -2
View File
@@ -110,8 +110,18 @@ export class InteriorAPI extends BaseSQLDataSource {
Scopes.INTERIORS_PUBLIC_READ,
]);
const sql = /* sql */ `
SELECT rooms.*, room_types.name roomType FROM rooms
LEFT JOIN room_types ON rooms.room_type_id = room_types.id
SELECT
r.*,
r.id,
r.name as room_name,
(ARRAY_AGG(rt.name ORDER BY rt.name) FILTER (WHERE rt.name IS NOT NULL))[1]
AS roomtype,
ARRAY_AGG(rt.name ORDER BY rt.name) FILTER (WHERE rt.name IS NOT NULL) AS roomtypes
FROM rooms r
LEFT JOIN room_roomtypes rrt ON r.id = rrt.room_id
LEFT JOIN roomtypes rt ON rrt.roomtype_id = rt.id
GROUP BY r.id, r.name
ORDER BY r.id;
`;
const allInteriors = await this.cachedRaw(sql, null)
@@ -122,6 +132,7 @@ export class InteriorAPI extends BaseSQLDataSource {
...row,
roomName: row.name,
roomType: row.roomtype,
roomTypes: row.roomtypes,
id: row.s3_suffix,
};
this.decorateRow(res);
+1
View File
@@ -374,6 +374,7 @@ type Interior {
roomName: String
position: Int
roomType: String
roomTypes: [String]
"""
uri is set when there is a generated file on s3, null otherwise
"""