()
| 353 | } |
| 354 | |
| 355 | async migrateJobsFromFile() { |
| 356 | for (let jobId in this.jobs) { |
| 357 | const jobData = this.jobs[jobId]; |
| 358 | if (!jobData.data) { |
| 359 | continue; |
| 360 | } |
| 361 | const videos = jobData.data.videos ? jobData.data.videos : []; |
| 362 | delete jobData.data; // Remove videos from job data |
| 363 | |
| 364 | // Convert timestamps to Date objects |
| 365 | jobData.timeInitiated = new Date(jobData.timeInitiated); |
| 366 | jobData.timeCreated = new Date(jobData.timeCreated); |
| 367 | |
| 368 | try { |
| 369 | const jobInstance = await Job.create(jobData); // Create job entry |
| 370 | |
| 371 | // Create video entries and jobVideo relationships |
| 372 | for (let video of videos) { |
| 373 | let videoInstance; |
| 374 | try { |
| 375 | videoInstance = await Video.create(video); // Create video entry |
| 376 | } catch (error) { |
| 377 | logger.error({ err: error }, 'Error migrating video'); |
| 378 | } |
| 379 | |
| 380 | // Create jobVideo relationship |
| 381 | try { |
| 382 | await JobVideo.create({ |
| 383 | job_id: jobInstance.id, |
| 384 | video_id: videoInstance.id, |
| 385 | }); |
| 386 | } catch (error) { |
| 387 | logger.error({ err: error }, 'Error migrating jobVideo'); |
| 388 | } |
| 389 | } |
| 390 | } catch (error) { |
| 391 | logger.error({ err: error }, 'Error migrating job'); |
| 392 | } |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | getInProgressJobId() { |
| 397 | for (let id in this.jobs) { |
no outgoing calls
no test coverage detected