how to get the number of failed jobs?
In the queue section of the docs, it says that we can get the queue size.
However, we can't pass in the state we're looking for, and instead, there is a before field, which will get you the total number of jobs in what looks like a linear list of states.
In the job definition, the states are listed as:
state: 'created' | 'retry' | 'active' | 'completed' | 'cancelled' | 'failed';
This means we can probably make a query for each of the states and do some math to get the number for each state except failed, because there's no state after it to specify in the before field.
Is there a way to get the number of failed jobs or is there another way to get queue numbers?
You can write your own query against the table if you want. There is also an event monitor-states that could be used, but this may not exist by the time v11 is released
@timgit does pgboss expose a method to query the db through its connection? I'm using Drizzle, so I'd either have to hack around their raw query method or generate a schema for pgboss and use that.
Seems like a good thing to add to the API. It's not there yet.
I revisited this and remembered I expose this is already exposed via getDb()
Hey @timgit
getDb() is not in types file. I can make a PR for this if you approve this change
Approved.