Files
talk/services/scraper.js
T
Wyatt Johnson 435067f619 Scraping Fixes
- Fixed bugs with scraping graphql endpoint
- Added traceID to logging for jobs
2018-03-07 15:30:34 -07:00

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;