Speed up populate database script

pull/850/head
Chocobozzz 2018-07-18 14:17:54 +02:00
parent 68037af892
commit 7279b45581
2 changed files with 20 additions and 11 deletions

View File

@ -67,8 +67,6 @@ async function rateVideo (req: express.Request, res: express.Response) {
dislikes: dislikesToIncrement
}
// Even if we do not own the video we increment the attributes
// It is useful for the user to have a feedback
await videoInstance.increment(incrementQuery, sequelizeOptions)
await sendVideoRateChange(accountInstance, videoInstance, likesToIncrement, dislikesToIncrement, t)

View File

@ -38,15 +38,26 @@ async function start () {
// Forever
const fakeTab = Array.from(Array(1000000).keys())
await Bluebird.map(fakeTab, () => {
return Promise.all([
uploadCustom(server),
likeCustom(server),
dislikeCustom(server),
createUserCustom(server),
createCustomChannel(server)
]).catch(err => console.error(err))
}, { concurrency: 5 })
const funs = [
uploadCustom
// uploadCustom,
// uploadCustom,
// uploadCustom,
// likeCustom,
// createUserCustom,
// createCustomChannel
]
const promises = []
for (const fun of funs) {
promises.push(
Bluebird.map(fakeTab, () => {
return fun(server).catch(err => console.error(err))
}, { concurrency: 3 })
)
}
await Promise.all(promises)
}
function getRandomInt (min, max) {