added support for room_types (#183)
* added support for room_types * backwards compability
This commit is contained in:
@@ -110,8 +110,18 @@ export class InteriorAPI extends BaseSQLDataSource {
|
|||||||
Scopes.INTERIORS_PUBLIC_READ,
|
Scopes.INTERIORS_PUBLIC_READ,
|
||||||
]);
|
]);
|
||||||
const sql = /* sql */ `
|
const sql = /* sql */ `
|
||||||
SELECT rooms.*, room_types.name roomType FROM rooms
|
SELECT
|
||||||
LEFT JOIN room_types ON rooms.room_type_id = room_types.id
|
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)
|
const allInteriors = await this.cachedRaw(sql, null)
|
||||||
@@ -122,6 +132,7 @@ export class InteriorAPI extends BaseSQLDataSource {
|
|||||||
...row,
|
...row,
|
||||||
roomName: row.name,
|
roomName: row.name,
|
||||||
roomType: row.roomtype,
|
roomType: row.roomtype,
|
||||||
|
roomTypes: row.roomtypes,
|
||||||
id: row.s3_suffix,
|
id: row.s3_suffix,
|
||||||
};
|
};
|
||||||
this.decorateRow(res);
|
this.decorateRow(res);
|
||||||
|
|||||||
@@ -374,6 +374,7 @@ type Interior {
|
|||||||
roomName: String
|
roomName: String
|
||||||
position: Int
|
position: Int
|
||||||
roomType: String
|
roomType: String
|
||||||
|
roomTypes: [String]
|
||||||
"""
|
"""
|
||||||
uri is set when there is a generated file on s3, null otherwise
|
uri is set when there is a generated file on s3, null otherwise
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user