include top seeded entries only for non foreign provider by default
This commit is contained in:
@@ -5,7 +5,7 @@ const DATABASE_URI = process.env.DATABASE_URI;
|
||||
|
||||
const database = new Sequelize(DATABASE_URI, { logging: false });
|
||||
|
||||
async function getIds(type, startDate, endDate) {
|
||||
async function getIds(providers, type, startDate, endDate) {
|
||||
const idName = type === Type.ANIME ? 'kitsuId' : 'imdbId';
|
||||
const episodeCondition = type === Type.SERIES
|
||||
? 'AND files."imdbSeason" IS NOT NULL AND files."imdbEpisode" IS NOT NULL'
|
||||
@@ -13,9 +13,12 @@ async function getIds(type, startDate, endDate) {
|
||||
const dateCondition = startDate && endDate
|
||||
? `AND "uploadDate" BETWEEN '${startDate}' AND '${endDate}'`
|
||||
: ''
|
||||
const providersCondition = providers && providers.length
|
||||
? `AND provider in (${providers.map(it => `'${it}'`).join(',')})`
|
||||
: ''
|
||||
const query = `SELECT files."${idName}"
|
||||
FROM (SELECT torrents."infoHash", torrents.seeders FROM torrents
|
||||
WHERE seeders > 0 AND type = '${type}' ${dateCondition}
|
||||
WHERE seeders > 0 AND type = '${type}' ${providersCondition} ${dateCondition}
|
||||
) as torrents
|
||||
JOIN files ON torrents."infoHash" = files."infoHash"
|
||||
WHERE files."${idName}" IS NOT NULL ${episodeCondition}
|
||||
|
||||
Reference in New Issue
Block a user