aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-02-26 19:27:08 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-02-26 20:01:26 +0100
commitf282639b07deee1e35403bd86c46ea521fb4845e (patch)
tree574b389ca2b03ffd4a5dadcf634d72c3d88593e6 /server
parent9c2c18f3ab2cf18aeb1eb38da48f0ba553f5d9be (diff)
downloadPeerTube-f282639b07deee1e35403bd86c46ea521fb4845e.tar.gz
PeerTube-f282639b07deee1e35403bd86c46ea521fb4845e.tar.zst
PeerTube-f282639b07deee1e35403bd86c46ea521fb4845e.zip
Server: request scheduler refractoring
Diffstat (limited to 'server')
-rw-r--r--server/lib/base-request-scheduler.js8
-rw-r--r--server/lib/request-video-qadu-scheduler.js11
2 files changed, 5 insertions, 14 deletions
diff --git a/server/lib/base-request-scheduler.js b/server/lib/base-request-scheduler.js
index d15680c25..309c1a261 100644
--- a/server/lib/base-request-scheduler.js
+++ b/server/lib/base-request-scheduler.js
@@ -95,14 +95,6 @@ module.exports = class BaseRequestScheduler {
95 const requestToMake = requestsToMakeGrouped[hashKey] 95 const requestToMake = requestsToMakeGrouped[hashKey]
96 const toPod = requestToMake.toPod 96 const toPod = requestToMake.toPod
97 97
98 // Maybe the pod is not our friend anymore so simply remove it
99 if (!toPod) {
100 const requestIdsToDelete = requestToMake.ids
101
102 logger.info('Removing %d "%s" of unexisting pod %s.', requestIdsToDelete.length, this.description, requestToMake.toPod.id)
103 return this.getRequestToPodModel().removePodOf(requestIdsToDelete, requestToMake.toPod.id, callbackEach)
104 }
105
106 this.makeRequest(toPod, requestToMake.endpoint, requestToMake.datas, (success) => { 98 this.makeRequest(toPod, requestToMake.endpoint, requestToMake.datas, (success) => {
107 if (success === false) { 99 if (success === false) {
108 badPods.push(requestToMake.toPod.id) 100 badPods.push(requestToMake.toPod.id)
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]