* select_next_page get the next url (page) to crawl
(callback)
| 295 | * select_next_page get the next url (page) to crawl |
| 296 | */ |
| 297 | function select_next_page (callback) { |
| 298 | connect( function () { |
| 299 | const query = `SELECT next_page, COUNT (next_page) AS c |
| 300 | FROM logs |
| 301 | WHERE next_page IS NOT null |
| 302 | AND next_page NOT IN ( |
| 303 | SELECT url |
| 304 | FROM logs |
| 305 | WHERE url IS NOT NULL |
| 306 | ) |
| 307 | GROUP BY next_page |
| 308 | ORDER BY c ASC |
| 309 | LIMIT 1;`; |
| 310 | // console.log('L82: query:', query); |
| 311 | PG_CLIENT.query(query, function(error, data) { |
| 312 | utils.log_error(error, data, new Error().stack); |
| 313 | return utils.exec_cb(callback, error, data); |
| 314 | }); |
| 315 | }); |
| 316 | } |
| 317 | |
| 318 | module.exports = { |
| 319 | connect: connect, |