Refactor giai đoạn 1: test các tính năng vừa thay đổi như tour, scene...

This commit is contained in:
2026-06-10 21:58:45 +07:00
parent 3f1b31b233
commit 358a98b21b
31 changed files with 1391 additions and 638 deletions
+15 -4
View File
@@ -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(() => {});