Skip to content

Instantly share code, notes, and snippets.

/stats.pl Secret

Created April 20, 2016 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/08ce391d514740e05d8d99f53aa43ade to your computer and use it in GitHub Desktop.
Save anonymous/08ce391d514740e05d8d99f53aa43ade to your computer and use it in GitHub Desktop.
$self->pg->db->query(
"with queues as (select distinct queue from minion_jobs),
states as (
select unnest(array['active', 'failed', 'finished', 'inactive'])
as state
)
select json_object_agg(queue, (
select jsonb_object_agg(state || '_jobs', (
select count(*) from minion_jobs where state::text = states.state and queue = queues.queue
))
from states
)) from queues"
)->expand->array->[0];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment