X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fpod.js;h=8e2d488e109dd4036287e839adbfee6a2f699324;hb=85cd99dc84cea7e9f428f251214bcdae428a9843;hp=14814708eaa70a0c5ae46f927af8d06b03c28843;hpb=9e167724f7e933f41d9ea2e1c31772bf4c560a28;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/pod.js b/server/models/pod.js index 14814708e..8e2d488e1 100644 --- a/server/models/pod.js +++ b/server/models/pod.js @@ -148,7 +148,12 @@ function listAllIds (transaction, callback) { }) } -function listRandomPodIdsWithRequest (limit, tableRequestPod, callback) { +function listRandomPodIdsWithRequest (limit, tableWithPods, tableWithPodsJoins, callback) { + if (!callback) { + callback = tableWithPodsJoins + tableWithPodsJoins = '' + } + const self = this self.count().asCallback(function (err, count) { @@ -170,7 +175,7 @@ function listRandomPodIdsWithRequest (limit, tableRequestPod, callback) { where: { id: { $in: [ - this.sequelize.literal('SELECT "podId" FROM "' + tableRequestPod + '"') + this.sequelize.literal(`SELECT DISTINCT "${tableWithPods}"."podId" FROM "${tableWithPods}" ${tableWithPodsJoins}`) ] } }