From 8d0a7a7b5a8dcf2daba61bbcebb30359e1a7354d Mon Sep 17 00:00:00 2001 From: cam Date: Mon, 3 Feb 2020 20:36:50 +1300 Subject: [PATCH 1/2] Add devices field when device doesn't have a ScheduleId yet --- api/V1/Schedule.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api/V1/Schedule.ts b/api/V1/Schedule.ts index 36661a0c..172c76ea 100644 --- a/api/V1/Schedule.ts +++ b/api/V1/Schedule.ts @@ -142,6 +142,10 @@ async function getSchedule(device: any, response: Response, user = null) { resData.devices = await models.Device.onlyUsersDevicesMatching(user, { ScheduleId: device.ScheduleId }); + } else if (user) { + resData.devices = await models.Device.onlyUsersDevicesMatching(user, { + id: device.id + }); } return responseUtil.send(response, resData); } From 4fb397ddd786c02fa1979a01ff3309fa15b85e39 Mon Sep 17 00:00:00 2001 From: cam Date: Wed, 5 Feb 2020 23:58:00 +1300 Subject: [PATCH 2/2] Add systemError as tag type and update how JSONB are compared in sequelize --- models/DetailSnapshot.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/models/DetailSnapshot.ts b/models/DetailSnapshot.ts index a5fef5bd..7e899b61 100644 --- a/models/DetailSnapshot.ts +++ b/models/DetailSnapshot.ts @@ -27,7 +27,7 @@ export interface DetailSnapShot ModelCommon { getFile: () => Promise; id: DetailSnapshotId; - type: "algorithm" | "throttle" | "audioBait"; + type: "algorithm" | "throttle" | "audioBait" | "systemError"; details: any; // JSON } @@ -79,7 +79,9 @@ export default function(sequelize, DataTypes): DetailSnapshotStatic { const existing = await this.findOne({ where: { type: searchType, - details: searchDetails + details: { + [Op.eq]: searchDetails, // Need to specify the equal operator as it's a JSONB + }, } });