]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/pod.js
Use yarn instead of npm install
[github/Chocobozzz/PeerTube.git] / server / models / pod.js
index 14814708eaa70a0c5ae46f927af8d06b03c28843..8e2d488e109dd4036287e839adbfee6a2f699324 100644 (file)
@@ -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}`)
           ]
         }
       }