[scraper] adds update seeders cron

This commit is contained in:
TheBeastLT
2020-04-08 15:53:02 +02:00
parent d3cc8c6b57
commit ce0e330172
10 changed files with 118 additions and 52 deletions

View File

@@ -1,3 +1,4 @@
const moment = require('moment');
const { Sequelize, fn, col, literal } = require('sequelize');
const Op = Sequelize.Op;
@@ -119,11 +120,18 @@ function getTorrentsBasedOnTitle(titleQuery, type) {
function getTorrentsWithoutSize() {
return Torrent.findAll({
where: literal(
'exists (select 1 from files where files."infoHash" = torrent."infoHash" and files.size = 300000000) and random() < 0.01'),
'exists (select 1 from files where files."infoHash" = torrent."infoHash" and files.size = 300000000)'),
order: [
['seeders', 'DESC']
],
limit: 1000
]
});
}
function getUpdateSeedersTorrents() {
const until = moment().subtract(7, 'days').format('YYYY-MM-DD');
return Torrent.findAll({
where: literal(`torrent."updatedAt" < \'${until}\' and random() < 0.001`),
limit: 100
});
}
@@ -186,6 +194,7 @@ module.exports = {
createTorrent,
getTorrent,
getTorrentsBasedOnTitle,
getUpdateSeedersTorrents,
createFile,
getFiles,
getFilesBasedOnTitle,