update seeders for new torrents

This commit is contained in:
TheBeastLT
2021-09-17 20:37:09 +02:00
parent b0029dcf5a
commit e4c4259ed8
4 changed files with 45 additions and 10 deletions

View File

@@ -24,6 +24,7 @@ function initiateRemoteCache() {
options: {
collection: 'torrentio_scraper_collection',
useUnifiedTopology: true,
poolSize: 1
},
ttl: GLOBAL_TTL,
ignoreCacheErrors: true

View File

@@ -187,7 +187,7 @@ function getTorrentsWithoutSize() {
});
}
function getUpdateSeedersTorrents(limit = 100) {
function getUpdateSeedersTorrents(limit = 50) {
const until = moment().subtract(7, 'days').format('YYYY-MM-DD');
return Torrent.findAll({
where: literal(`torrent."updatedAt" < \'${until}\'`),
@@ -199,6 +199,19 @@ function getUpdateSeedersTorrents(limit = 100) {
});
}
function getUpdateSeedersNewTorrents(limit = 50) {
const lastUpdate = moment().subtract(12, 'hours').format('YYYY-MM-DD');
const createdAfter = moment().subtract(4, 'days').format('YYYY-MM-DD');
return Torrent.findAll({
where: literal(`torrent."updatedAt" < \'${lastUpdate}\' AND torrent."createdAt" > \'${createdAfter}\'`),
limit: limit,
order: [
['seeders', 'ASC'],
['updatedAt', 'ASC']
]
});
}
function getNoContentsTorrents() {
return Torrent.findAll({
where: { opened: false, seeders: { [Op.gte]: 1 } },
@@ -315,6 +328,7 @@ module.exports = {
getTorrentsBasedOnQuery,
deleteTorrent,
getUpdateSeedersTorrents,
getUpdateSeedersNewTorrents,
getNoContentsTorrents,
createFile,
getFiles,