aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-07-18 14:17:54 +0200
committerChocobozzz <me@florianbigard.com>2018-07-24 14:04:05 +0200
commit7279b455811f4806dcb74a08d17b837bc22533c1 (patch)
treea92c93f330b86fb76b4c7b8bd7f640ddb2c7d16d
parent68037af8926a348fe03dc0b3b95a9553d246de20 (diff)
downloadPeerTube-7279b455811f4806dcb74a08d17b837bc22533c1.tar.gz
PeerTube-7279b455811f4806dcb74a08d17b837bc22533c1.tar.zst
PeerTube-7279b455811f4806dcb74a08d17b837bc22533c1.zip
Speed up populate database script
-rw-r--r--server/controllers/api/videos/rate.ts2
-rw-r--r--server/tests/real-world/populate-database.ts29
2 files changed, 20 insertions, 11 deletions
diff --git a/server/controllers/api/videos/rate.ts b/server/controllers/api/videos/rate.ts
index 9d63b5821..b1732837d 100644
--- a/server/controllers/api/videos/rate.ts
+++ b/server/controllers/api/videos/rate.ts
@@ -67,8 +67,6 @@ async function rateVideo (req: express.Request, res: express.Response) {
67 dislikes: dislikesToIncrement 67 dislikes: dislikesToIncrement
68 } 68 }
69 69
70 // Even if we do not own the video we increment the attributes
71 // It is useful for the user to have a feedback
72 await videoInstance.increment(incrementQuery, sequelizeOptions) 70 await videoInstance.increment(incrementQuery, sequelizeOptions)
73 71
74 await sendVideoRateChange(accountInstance, videoInstance, likesToIncrement, dislikesToIncrement, t) 72 await sendVideoRateChange(accountInstance, videoInstance, likesToIncrement, dislikesToIncrement, t)
diff --git a/server/tests/real-world/populate-database.ts b/server/tests/real-world/populate-database.ts
index f0f82f7f8..d41ac8d36 100644
--- a/server/tests/real-world/populate-database.ts
+++ b/server/tests/real-world/populate-database.ts
@@ -38,15 +38,26 @@ async function start () {
38 38
39 // Forever 39 // Forever
40 const fakeTab = Array.from(Array(1000000).keys()) 40 const fakeTab = Array.from(Array(1000000).keys())
41 await Bluebird.map(fakeTab, () => { 41 const funs = [
42 return Promise.all([ 42 uploadCustom
43 uploadCustom(server), 43 // uploadCustom,
44 likeCustom(server), 44 // uploadCustom,
45 dislikeCustom(server), 45 // uploadCustom,
46 createUserCustom(server), 46 // likeCustom,
47 createCustomChannel(server) 47 // createUserCustom,
48 ]).catch(err => console.error(err)) 48 // createCustomChannel
49 }, { concurrency: 5 }) 49 ]
50 const promises = []
51
52 for (const fun of funs) {
53 promises.push(
54 Bluebird.map(fakeTab, () => {
55 return fun(server).catch(err => console.error(err))
56 }, { concurrency: 3 })
57 )
58 }
59
60 await Promise.all(promises)
50} 61}
51 62
52function getRandomInt (min, max) { 63function getRandomInt (min, max) {