| @@ -45,7 +45,7 @@ agenda.define('scrape', async function (job, done) { | |||
| properties.push(property); | |||
| console.log(`${link} scraped.`); | |||
| limit++; | |||
| }catch(err){ | |||
| } catch (err) { | |||
| console.error(`${link} scrape failed.`); | |||
| } | |||
| } | |||
| @@ -116,6 +116,7 @@ app.get("/scrapes/:id", async (req, res) => { | |||
| }); | |||
| app.post("/scrapes/", async (req, res) => { | |||
| const location = req.body.location; | |||
| const description = req.body.description; | |||
| const price = req.body.price; | |||
| const beds = req.body.beds; | |||
| const type = req.body.type; | |||
| @@ -171,13 +172,14 @@ app.post("/scrapes/", async (req, res) => { | |||
| const dbo = client.db(database); | |||
| let collection = dbo.collection('scrapes'); | |||
| const dt = new Date(); | |||
| dt.setSeconds( dt.getSeconds() + resultCount ); | |||
| dt.setSeconds(dt.getSeconds() + resultCount); | |||
| let res = await collection.insertOne({ | |||
| count: resultCount, | |||
| pageCount: pagesCount, | |||
| estimate: dt, | |||
| sourceUrl: query, | |||
| location: location, | |||
| description: description, | |||
| filters: [ | |||
| { name: 'price', value: price }, | |||
| { name: 'beds', value: beds }, | |||