New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: views | queues & stats #2
Conversation
2can
commented
Apr 13, 2017
•
edited
edited
lib/web/routes/home.js
Outdated
let busy = await Job.activeSize(); | ||
let sizes = await Queue.sizes(await Queue.all()); | ||
let queued = Object.keys(sizes).reduce((acc, queue) => { | ||
return acc += sizes[queue]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@2can implicit return
lib/web/routes/home.js
Outdated
async function dashboard(ctx, next) { | ||
await ctx.render('index', {}); | ||
let done = await Job.processedSize(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@2can group it with Promise.all
lib/web/routes/home.js
Outdated
let done = await Job.processedSize(); | ||
let failed = await Job.failedSize(); | ||
let busy = await Job.activeSize(); | ||
let sizes = await Queue.sizes(await Queue.all()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@2can let's make sizes
to return by default the size for all queues, no additional call
lib/queue.js
Outdated
@@ -38,15 +38,23 @@ class Queue extends EventEmitter { | |||
return `blezer:queues:${this.name}` | |||
} | |||
|
|||
get jobs() { | |||
static jobs() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@2can this cannot be static, cf this
below
lib/queue.js
Outdated
return redis.lrangeAsync(this.path, 0, -1); | ||
} | ||
|
||
get size() { | ||
return redis.llenAsync(this.path); | ||
static size(name = 'default') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@2can it'd be more coherent to not use it as static
lib/queue.js
Outdated
static get all() { | ||
static async sizes(names = ['default']) { | ||
let sizes = {}; | ||
for (const name of names) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@2can this is an antipattern http://eslint.org/docs/rules/no-await-in-loop
8189723
to
bd225b4
Compare
@zaiste done |