mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-27 22:54:53 +00:00
Update device status logs to handle multiple properties
This commit is contained in:
@ -187,19 +187,19 @@ export class DeviceStatusFirebaseService {
|
||||
code,
|
||||
value,
|
||||
}));
|
||||
const newLog = this.deviceStatusLogRepository.create({
|
||||
deviceId: addDeviceStatusDto.deviceUuid,
|
||||
deviceTuyaId: addDeviceStatusDto.deviceTuyaUuid,
|
||||
productId: addDeviceStatusDto.log.productId,
|
||||
log: addDeviceStatusDto.log,
|
||||
code: existingData.status[0].code,
|
||||
value: existingData.status[0].value,
|
||||
eventId: addDeviceStatusDto.log.dataId,
|
||||
eventTime: new Date(
|
||||
addDeviceStatusDto.log.properties[0].time,
|
||||
).toISOString(),
|
||||
const newLogs = addDeviceStatusDto.log.properties.map((property) => {
|
||||
return this.deviceStatusLogRepository.create({
|
||||
deviceId: addDeviceStatusDto.deviceUuid,
|
||||
deviceTuyaId: addDeviceStatusDto.deviceTuyaUuid,
|
||||
productId: addDeviceStatusDto.log.productId,
|
||||
log: addDeviceStatusDto.log,
|
||||
code: property.code,
|
||||
value: property.value,
|
||||
eventId: addDeviceStatusDto.log.dataId,
|
||||
eventTime: new Date(property.time).toISOString(),
|
||||
});
|
||||
});
|
||||
await this.deviceStatusLogRepository.save(newLog);
|
||||
await this.deviceStatusLogRepository.save(newLogs);
|
||||
// Save the updated data to Firebase
|
||||
await set(dataRef, existingData);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user