Ajouter la mise à jour du fichier vidéo et gérer les erreurs lors du rendu

This commit is contained in:
2025-02-12 11:23:30 +01:00
parent 269ad2283d
commit a63e79e26e
2 changed files with 20 additions and 2 deletions

View File

@@ -315,13 +315,23 @@ router.post('/videos/render/:video_id', (req, res) => {
const project_id = results.rows[0].project_id;
console.log('Measurement IDs:', measurementIds);
console.log('Project ID:', project_id);
measureManager.getPathList(measurementIds, project_id).then(pathList => {
const pathList = measureManager.getPathList(measurementIds, project_id).then(pathList => {
console.log('Path list:', pathList);
res.json({ message: 'Render process started' });
}).catch(err => {
console.error('Error getting path list:', err);
res.status(500).json({ error: 'Error getting path list' });
});
const videoFile = createVideoWithList(project_id, pathList);
console.log('Video file:', videoFile);
try {
videoManager.updateVideoFile(videoId, videoFile);
} catch (err) {
console.error('Error updating video file:', err);
res.status(500).json({ error: 'Error updating video file' });
}
});
});

View File

@@ -126,4 +126,12 @@ async function createVideo(projectId) {
}
}
module.exports = { createVideo, createVideoWithList, createVideoProject, deleteVideoProject };
async function updateVideoFile(videoId, path) {
const query = 'UPDATE public.videos SET video_file = $2 WHERE id = $1 RETURNING *';
const values = [videoId, path];
const res = await db.query(query, values);
console.log('Video updated:', res.rows[0]);
return res.rows[0];
}
module.exports = { createVideo, createVideoWithList, createVideoProject, deleteVideoProject, updateVideoFile };