Fix join in video events
authorChocobozzz <florian.bigard@gmail.com>
Thu, 26 Oct 2017 09:42:36 +0000 (11:42 +0200)
committerChocobozzz <florian.bigard@gmail.com>
Thu, 26 Oct 2017 09:42:36 +0000 (11:42 +0200)
server/models/request/request-video-event.ts

index 34d5c71622149b2891b9557304cac17b6922ccc4..d7dce9bc83e0754c836cf021388c740d73471517 100644 (file)
@@ -102,15 +102,20 @@ listWithLimitAndRandom = function (limitPods: number, limitRequestsPerPod: numbe
           model: RequestVideoEvent['sequelize'].models.Video,
           include: [
             {
-              model: RequestVideoEvent['sequelize'].models.Author,
+              model: RequestVideoEvent['sequelize'].models.VideoChannel,
               include: [
                 {
-                  model: RequestVideoEvent['sequelize'].models.Pod,
-                  where: {
-                    id: {
-                      $in: podIds
+                  model: RequestVideoEvent['sequelize'].models.Author,
+                  include: [
+                    {
+                      model: RequestVideoEvent['sequelize'].models.Pod,
+                      where: {
+                        id: {
+                          $in: podIds
+                        }
+                      }
                     }
-                  }
+                  ]
                 }
               ]
             }
@@ -138,10 +143,15 @@ removeByRequestIdsAndPod = function (ids: number[], podId: number) {
         model: RequestVideoEvent['sequelize'].models.Video,
         include: [
           {
-            model: RequestVideoEvent['sequelize'].models.Author,
-            where: {
-              podId
-            }
+            model: RequestVideoEvent['sequelize'].models.VideoChannel,
+            include: [
+              {
+                model: RequestVideoEvent['sequelize'].models.Author,
+                where: {
+                  podId
+                }
+              }
+            ]
           }
         ]
       }