feat: add arguments to created commands

This commit is contained in:
Valentin Kaelin 2019-12-16 20:51:46 +01:00
parent 46aed5a435
commit d106e84db1
2 changed files with 11 additions and 7 deletions

View file

@ -8,7 +8,8 @@ class DeleteMatch extends Command {
static get signature() {
return `
delete:match
{ field : Delete row if entered field is null }
{ 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()

View file

@ -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()