diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-02-26 19:27:08 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-02-26 20:01:26 +0100 |
commit | f282639b07deee1e35403bd86c46ea521fb4845e (patch) | |
tree | 574b389ca2b03ffd4a5dadcf634d72c3d88593e6 /server/lib/request-video-qadu-scheduler.js | |
parent | 9c2c18f3ab2cf18aeb1eb38da48f0ba553f5d9be (diff) | |
download | PeerTube-f282639b07deee1e35403bd86c46ea521fb4845e.tar.gz PeerTube-f282639b07deee1e35403bd86c46ea521fb4845e.tar.zst PeerTube-f282639b07deee1e35403bd86c46ea521fb4845e.zip |
Server: request scheduler refractoring
Diffstat (limited to 'server/lib/request-video-qadu-scheduler.js')
-rw-r--r-- | server/lib/request-video-qadu-scheduler.js | 11 |
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] |