]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/request-video-qadu-scheduler.js
Server: typo
[github/Chocobozzz/PeerTube.git] / server / lib / request-video-qadu-scheduler.js
index 401b2fb441c0b01252185ac2b2acd354b3f28f39..ac50cfc111e7495f50bfe0585996146a8b9e85ad 100644 (file)
@@ -6,13 +6,12 @@ const db = require('../initializers/database')
 const logger = require('../helpers/logger')
 
 module.exports = class RequestVideoQaduScheduler extends BaseRequestScheduler {
-
   constructor () {
     super()
 
     // We limit the size of the requests
     this.limitPods = constants.REQUESTS_VIDEO_QADU_LIMIT_PODS
-    this.limitPerPod = constants.REQUESTS_VIDEO_QADU_LIMIT_PODS
+    this.limitPerPod = constants.REQUESTS_VIDEO_QADU_LIMIT_PER_POD
 
     this.description = 'video QADU requests'
   }
@@ -38,19 +37,14 @@ module.exports = class RequestVideoQaduScheduler extends BaseRequestScheduler {
         if (!requestsToMakeGrouped[hashKey]) {
           requestsToMakeGrouped[hashKey] = {
             toPod: pod,
-            endpoint: constants.REQUEST_ENDPOINTS.QADU,
+            endpoint: constants.REQUEST_VIDEO_QADU_ENDPOINT,
             ids: [], // request ids, to delete them from the DB in the future
             datas: [], // requests data
             videos: {}
           }
         }
 
-        if (!requestsToMakeGrouped[hashKey].videos[video.id]) {
-          requestsToMakeGrouped[hashKey].videos[video.id] = {}
-        }
-
-        const videoData = requestsToMakeGrouped[hashKey].videos[video.id]
-
+        const videoData = {}
         switch (request.type) {
           case constants.REQUEST_VIDEO_QADU_TYPES.LIKES:
             videoData.likes = video.likes
@@ -72,10 +66,14 @@ module.exports = class RequestVideoQaduScheduler extends BaseRequestScheduler {
         // Do not forget the remoteId so the remote pod can identify the video
         videoData.remoteId = video.id
         requestsToMakeGrouped[hashKey].ids.push(request.id)
+
+        // Maybe there are multiple quick and dirty update for the same video
+        // We use this hashmap to dedupe them
         requestsToMakeGrouped[hashKey].videos[video.id] = videoData
       })
     })
 
+    // Now we deduped similar quick and dirty updates, we can build our requests datas
     Object.keys(requestsToMakeGrouped).forEach(hashKey => {
       Object.keys(requestsToMakeGrouped[hashKey].videos).forEach(videoId => {
         const videoData = requestsToMakeGrouped[hashKey].videos[videoId]