MCPcopy Create free account
hub / github.com/DialmasterOrg/Youtarr / loadJobsFromDB

Method loadJobsFromDB

server/modules/jobModule.js:326–353  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

324 }
325
326 async loadJobsFromDB() {
327 try {
328 const jobs = await Job.findAll();
329 const jobVideos = await JobVideo.findAll();
330
331 this.jobs = {};
332
333 for (let job of jobs) {
334 this.jobs[job.id] = {
335 ...job.dataValues,
336 data: {
337 videos: [],
338 },
339 // Don't restore action functions - pending jobs will be terminated on startup
340 // since they can't be safely resumed (missing urls, etc.)
341 };
342 }
343
344 for (let jobVideo of jobVideos) {
345 const video = await Video.findOne({ where: { id: jobVideo.video_id } });
346 if (video && this.jobs[jobVideo.job_id]) {
347 this.jobs[jobVideo.job_id].data.videos.push(video.dataValues);
348 }
349 }
350 } catch (error) {
351 logger.error({ err: error }, 'Error loading jobs from DB');
352 }
353 }
354
355 async migrateJobsFromFile() {
356 for (let jobId in this.jobs) {

Callers 2

constructorMethod · 0.95
jobModule.test.jsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected