mirror of
https://github.com/wassname/talk.git
synced 2026-06-29 04:11:26 +08:00
435067f619
- Fixed bugs with scraping graphql endpoint - Added traceID to logging for jobs
34 lines
670 B
JavaScript
34 lines
670 B
JavaScript
const kue = require('./kue');
|
|
|
|
/**
|
|
* Exposes a service object to allow operations to execute against the scraper.
|
|
* @type {Object}
|
|
*/
|
|
const scraper = {
|
|
/**
|
|
* Create the new Task kue singleton.
|
|
*/
|
|
task: new kue.Task({
|
|
name: 'scraper',
|
|
}),
|
|
|
|
/**
|
|
* Creates a new scraper job and scrapes the url when it gets processed.
|
|
*/
|
|
async create(ctx, id) {
|
|
ctx.log.info({ assetID: id }, 'Creating job');
|
|
|
|
const job = await scraper.task.create({
|
|
title: `Scrape for asset ${id}`,
|
|
id: ctx.id,
|
|
asset_id: id,
|
|
});
|
|
|
|
ctx.log.info({ jobID: job.id, assetID: id }, 'Created job');
|
|
|
|
return job;
|
|
},
|
|
};
|
|
|
|
module.exports = scraper;
|