-
-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more camera rotation (90°, 180°, 270°) (#1823)
- Loading branch information
Showing
9 changed files
with
230 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
server/migrations/20230628144609-change-rotation-camera.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const Promise = require('bluebird'); | ||
const db = require('../models'); | ||
const logger = require('../utils/logger'); | ||
|
||
module.exports = { | ||
up: async (queryInterface, Sequelize) => { | ||
const service = await db.Service.findOne({ | ||
where: { | ||
name: 'rtsp-camera', | ||
}, | ||
}); | ||
if (service === null) { | ||
return; | ||
} | ||
logger.info(`RstpCamera migration: Found service rtsp-camera = ${service.id}`); | ||
const cameraDevices = await db.Device.findAll({ | ||
where: { | ||
service_id: service.id, | ||
}, | ||
}); | ||
logger.info(`RstpCamera migration: Found ${cameraDevices.length} devices`); | ||
await Promise.each(cameraDevices, async (enedisDevice) => { | ||
const deviceParam = await db.DeviceParam.findOne({ | ||
where: { | ||
device_id: enedisDevice.id, | ||
name: 'CAMERA_ROTATION', | ||
}, | ||
}); | ||
if (deviceParam === null) { | ||
return; | ||
} | ||
if (deviceParam.value === '1') { | ||
logger.info(`RstpCamera migration: Updating device_params ${deviceParam.id} with 180°`); | ||
deviceParam.set({ | ||
value: '180', | ||
}); | ||
await deviceParam.save(); | ||
} | ||
}); | ||
}, | ||
down: async (queryInterface, Sequelize) => {}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.