aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/request-video-qadu-scheduler.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/request-video-qadu-scheduler.js')
-rw-r--r--server/lib/request-video-qadu-scheduler.js11
1 files changed, 5 insertions, 6 deletions
diff --git a/server/lib/request-video-qadu-scheduler.js b/server/lib/request-video-qadu-scheduler.js
index 29e44a6c4..33b1c6d28 100644
--- a/server/lib/request-video-qadu-scheduler.js
+++ b/server/lib/request-video-qadu-scheduler.js
@@ -45,12 +45,7 @@ module.exports = class RequestVideoQaduScheduler extends BaseRequestScheduler {
45 } 45 }
46 } 46 }
47 47
48 if (!requestsToMakeGrouped[hashKey].videos[video.id]) { 48 const videoData = {}
49 requestsToMakeGrouped[hashKey].videos[video.id] = {}
50 }
51
52 const videoData = requestsToMakeGrouped[hashKey].videos[video.id]
53
54 switch (request.type) { 49 switch (request.type) {
55 case constants.REQUEST_VIDEO_QADU_TYPES.LIKES: 50 case constants.REQUEST_VIDEO_QADU_TYPES.LIKES:
56 videoData.likes = video.likes 51 videoData.likes = video.likes
@@ -72,10 +67,14 @@ module.exports = class RequestVideoQaduScheduler extends BaseRequestScheduler {
72 // Do not forget the remoteId so the remote pod can identify the video 67 // Do not forget the remoteId so the remote pod can identify the video
73 videoData.remoteId = video.id 68 videoData.remoteId = video.id
74 requestsToMakeGrouped[hashKey].ids.push(request.id) 69 requestsToMakeGrouped[hashKey].ids.push(request.id)
70
71 // Maybe there are multiple quick and dirty update for the same video
72 // We use this hashmap to dedupe them
75 requestsToMakeGrouped[hashKey].videos[video.id] = videoData 73 requestsToMakeGrouped[hashKey].videos[video.id] = videoData
76 }) 74 })
77 }) 75 })
78 76
77 // Now we deduped similar quick and dirty updates, we can build our requests datas
79 Object.keys(requestsToMakeGrouped).forEach(hashKey => { 78 Object.keys(requestsToMakeGrouped).forEach(hashKey => {
80 Object.keys(requestsToMakeGrouped[hashKey].videos).forEach(videoId => { 79 Object.keys(requestsToMakeGrouped[hashKey].videos).forEach(videoId => {
81 const videoData = requestsToMakeGrouped[hashKey].videos[videoId] 80 const videoData = requestsToMakeGrouped[hashKey].videos[videoId]