Refactor giai đoạn 1: test các tính năng vừa thay đổi như tour, scene...
This commit is contained in:
@@ -23,14 +23,25 @@ const imageWorker = new Worker('image-processing', async (job) => {
|
||||
// 3. Chèn GPS Metadata
|
||||
await injectGPSCoordinates(processedFilePath, latitude, longitude);
|
||||
|
||||
// 4. Cập nhật đường dẫn file thực tế vào Database
|
||||
// Lúc này ảnh đã sẵn sàng để phục vụ (8K)
|
||||
await Asset.findByIdAndUpdate(assetId, { filePath: processedFilePath });
|
||||
await Scene.findByIdAndUpdate(sceneId, {
|
||||
// 4. Cập nhật đồng thời cả Asset và Scene
|
||||
await Asset.findByIdAndUpdate(assetId, {
|
||||
filePath: processedFilePath
|
||||
}, { returnDocument: 'after' });
|
||||
|
||||
const scene = await Scene.findByIdAndUpdate(sceneId, {
|
||||
scene_url: processedFilePath,
|
||||
status: 'completed' // Xử lý xong
|
||||
}, {
|
||||
// Thay thế 'new: true' bằng 'returnDocument: after' để tránh cảnh báo deprecation
|
||||
returnDocument: 'after'
|
||||
});
|
||||
|
||||
// 4.1 Tự động tính toán lại vị trí trung tâm của Tour sau khi ảnh đã được xử lý và chèn GPS thành công
|
||||
if (scene && scene.tourId) {
|
||||
const tourController = require('../middlewares/TourController');
|
||||
if (tourController.updateTourCenter) await tourController.updateTourCenter(scene.tourId);
|
||||
}
|
||||
|
||||
// 5. Dọn dẹp file tạm
|
||||
await fs.promises.unlink(tempFilePath).catch(() => {});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user