[scraper] try to fix seeders update startup error
This commit is contained in:
@@ -10,7 +10,7 @@ const statistics = {};
|
|||||||
|
|
||||||
function scheduleUpdateSeeders() {
|
function scheduleUpdateSeeders() {
|
||||||
console.log('Starting seeders update...')
|
console.log('Starting seeders update...')
|
||||||
return repository.getUpdateSeedersTorrents(50)
|
return getTorrents()
|
||||||
.then(torrents => updateCurrentSeeders(torrents))
|
.then(torrents => updateCurrentSeeders(torrents))
|
||||||
.then(updatedTorrents => Promise.all(
|
.then(updatedTorrents => Promise.all(
|
||||||
updatedTorrents.map(updated => updateLimiter.schedule(() => updateTorrentSeeders(updated)))))
|
updatedTorrents.map(updated => updateLimiter.schedule(() => updateTorrentSeeders(updated)))))
|
||||||
@@ -21,6 +21,11 @@ function scheduleUpdateSeeders() {
|
|||||||
.then(() => scheduleUpdateSeeders());
|
.then(() => scheduleUpdateSeeders());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getTorrents() {
|
||||||
|
return repository.getUpdateSeedersTorrents(50)
|
||||||
|
.catch(() => delay(5000).then(() => getTorrents()))
|
||||||
|
}
|
||||||
|
|
||||||
function updateStatistics(updatedTorrents) {
|
function updateStatistics(updatedTorrents) {
|
||||||
const totalTorrents = updatedTorrents.map(nested => nested.length).reduce((a, b) => a + b, 0);
|
const totalTorrents = updatedTorrents.map(nested => nested.length).reduce((a, b) => a + b, 0);
|
||||||
const date = new Date().toISOString().replace(/T.*/, '');
|
const date = new Date().toISOString().replace(/T.*/, '');
|
||||||
|
|||||||
Reference in New Issue
Block a user