From d106e84db1e1d2a1ef30f5f83bba12fceb7a24b5 Mon Sep 17 00:00:00 2001 From: Valentin Kaelin Date: Mon, 16 Dec 2019 20:51:46 +0100 Subject: [PATCH] feat: add arguments to created commands --- server/app/Commands/DeleteMatch.js | 7 ++++--- server/app/Commands/EditMatch.js | 11 +++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/server/app/Commands/DeleteMatch.js b/server/app/Commands/DeleteMatch.js index 1baf53e..f343527 100644 --- a/server/app/Commands/DeleteMatch.js +++ b/server/app/Commands/DeleteMatch.js @@ -7,8 +7,9 @@ const Match = use('App/Models/Match') class DeleteMatch extends Command { static get signature() { return ` - delete:match - { field : Delete row if entered field is null } + delete:match + { field : Field to check } + { value?=null : Value of the field, if true: delete match } ` } @@ -21,7 +22,7 @@ class DeleteMatch extends Command { const nbMatchesBefore = await Match.count() const matches = await Match.all() for (const match of matches.toJSON()) { - await Match.where('_id', match._id).where(args.field, null).delete() + await Match.where('_id', match._id).where(args.field, args.value).delete() } const nbMatchesAfter = await Match.count() Database.close() diff --git a/server/app/Commands/EditMatch.js b/server/app/Commands/EditMatch.js index d168433..a37637d 100644 --- a/server/app/Commands/EditMatch.js +++ b/server/app/Commands/EditMatch.js @@ -9,7 +9,10 @@ const Queue = use('Bee/Queue') class EditMatch extends Command { static get signature() { - return 'edit:match' + return ` + edit:match + { concurrent?=10 : Number of concurrent jobs } + ` } static get description() { @@ -19,8 +22,8 @@ class EditMatch extends Command { /** * Create edit-matches Queue */ - async createQueue() { - Queue.get('edit-matches').process(2, async (job) => { + createQueue(concurrent) { + Queue.get('edit-matches').process(concurrent, async (job) => { // Get stats from Riot API const matchRiot = await Jax.Match.get(job.data.gameId, job.data.region) const account = { @@ -48,7 +51,7 @@ class EditMatch extends Command { async handle(args, options) { console.time('EditMatches') - this.createQueue() + this.createQueue(args.concurrent) // All matches from the db const matches = await Match.all()