|
@ -70,6 +70,12 @@ class WebpageScreenshotJob extends SiteWorkerProcess { |
|
|
const imageFilename = path.join(process.env.DTP_IMAGE_WORK_PATH, 'webpage-screenshot', `${documentId}.jpg`); |
|
|
const imageFilename = path.join(process.env.DTP_IMAGE_WORK_PATH, 'webpage-screenshot', `${documentId}.jpg`); |
|
|
this.log.info('job received to capture webpage screenshot', { modelName, documentId, pageUrl }); |
|
|
this.log.info('job received to capture webpage screenshot', { modelName, documentId, pageUrl }); |
|
|
|
|
|
|
|
|
|
|
|
job.data.viewport = Object.assign({ |
|
|
|
|
|
width: 720, |
|
|
|
|
|
height: 600, |
|
|
|
|
|
deviceScaleFactor: 1.0, |
|
|
|
|
|
}, job.data.viewport); |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
job.data.document = await model.findById(documentId); |
|
|
job.data.document = await model.findById(documentId); |
|
|
if (!job.data.document) { |
|
|
if (!job.data.document) { |
|
@ -83,11 +89,7 @@ class WebpageScreenshotJob extends SiteWorkerProcess { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
await job.page.setUserAgent(userAgent.toString()); |
|
|
await job.page.setUserAgent(userAgent.toString()); |
|
|
await job.page.setViewport({ |
|
|
await job.page.setViewport(job.data.viewport); |
|
|
width: 720, |
|
|
|
|
|
height: 600, |
|
|
|
|
|
deviceScaleFactor: 1.0, |
|
|
|
|
|
}); |
|
|
|
|
|
await job.page.goto(pageUrl, { waitUntil: 'networkidle2' }); |
|
|
await job.page.goto(pageUrl, { waitUntil: 'networkidle2' }); |
|
|
|
|
|
|
|
|
this.jobLog(job, 'capturing screenshot to file'); |
|
|
this.jobLog(job, 'capturing screenshot to file'); |
|
@ -95,7 +97,7 @@ class WebpageScreenshotJob extends SiteWorkerProcess { |
|
|
path: imageFilename, |
|
|
path: imageFilename, |
|
|
type: 'jpeg', |
|
|
type: 'jpeg', |
|
|
quality: 85, |
|
|
quality: 85, |
|
|
fullPage: false, |
|
|
fullPage: job.data.fullPage || false, |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
this.jobLog(job, 'uploading screenshot to storage and database'); |
|
|
this.jobLog(job, 'uploading screenshot to storage and database'); |
|
|